在我的代码中,我有以下代码块
Tempfile.open([model.id.to_s, '.txt'], Rails.root.join('tmp')) do |file|
begin
file << somedata_i_have_before
model.file = file # using paperclip gem attached file
ensure
# close and delete file
file.close
file.unlink
end
end这个代码在本地和生产上都很好..。问题是我已经设置了威克应用程序来自动化测试和部署,但是上面提到的块在wercker上失败并返回以下错误
Errno::ENOENT:
No such file or directory @ rb_sysopen - /pipeline/build/tmp/539e01d4776572049647010020140615-1174-ajp5tf.txt
# ./lib/some_lib.rb:63:in `some_method'有什么办法可以解决这个问题,让构建上的wercker通过吗?
发布于 2014-06-16 09:33:31
我想您的存储库中忽略了tmp文件夹(.gitignore),所以当您执行干净的存储库克隆时不会创建它。
我可能错了,但是Tempfile.open([model.id.to_s, '.txt'], Rails.root.join('tmp'))没有创建tmp文件夹,它希望它已经存在了。
对于被忽略的文件夹,我也遇到了类似的问题--您可以使用一个干净的git克隆来测试它,然后执行这个测试,因为它将在CI/CD服务器上运行。
发布于 2014-06-16 10:01:05
问题是wercker没有创建tmp,要解决这个问题,只需将以下步骤添加到wercker.yml中(在运行规范之前)
- script:
name: create and grant writing permission to /tmp directory
code: |
mkdir $WERCKER_ROOT/tmp
chmod -R 755 $WERCKER_ROOT/tmp
echo "$(ls -l $WERCKER_ROOT)"
# A step that executes `rspec` command
- script:
name: rspec
code: bundle exec rspec并确保ls -l $WERCKER_ROOT包括以下内容
drwxr-xr-x 2 ubuntu ubuntu 4096 Jun 15 22:39 tmp解决此问题的另一种方法是创建tmp/.gitkeep并将其提交给您的回购。这也将解决这个问题(这是一个更清洁的解决方案)。
https://stackoverflow.com/questions/24233962
复制相似问题