Capistrano throws /usr/bin/env: ruby: No such file or directory when performing a deploy:migration

倾然丶 夕夏残阳落幕 提交于 2019-12-13 02:37:33

问题


I set up Capistrano to make the deploy of my app. I made it in steps, so first I set up the code deployment, so I commented all the roles but :app.

I'm using rvm and I had some problems with it. The biggest problem was an error that said /usr/bin/env: ruby: No such file or directory. I solved them using the gem capistrano/rvm and requiring it in the Capfile and adding the following line to the deploy.rb file:

set :default_env, { path: "/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:$PATH" }

Once the code deploying runned correctly I activated de :db role in order to perform migrations. I get the same error but I can't find the solution this time.

~$ cap production deploy:migrate
    …
    …
 INFO [85d6241d] Running bundle exec rake db:migrate on 10.10.51.10
 DEBUG [85d6241d] Command: cd [PROJECT_SRC]/current 
                  && ( PATH=/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:$PATH RAILS_ENV=production bundle exec rake db:migrate )
 DEBUG [85d6241d]            /usr/bin/env: ruby: No such file or directory
 cap aborted!

This command runs correctly when I execute it directly in the shell.

Thank you in advance!


回答1:


Finally it worked using gem 'rvm1-capistrano3', require: false. It seems the best option for my setup (Rails4.0.1, ruby-2.0.0-p247, capistrano3). It didn't require special configuration.

You can find it here.

Hope it helps someone!




回答2:


I had similar problem and this gem helped me: https://github.com/wayneeseguin/rvm-capistrano




回答3:


If you are not using rvm, then the issue is usually you'll have to manually install bundler gem on the server.

gem install bundler



回答4:


Have you tried offical capistrano gems? That helped me, maybe your use case is similiar.

Gemfile:

...
gem 'capistrano', '~> 3.2.0'
gem 'capistrano-rvm'
gem 'capistrano-rails'
...

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
...


来源:https://stackoverflow.com/questions/20996101/capistrano-throws-usr-bin-env-ruby-no-such-file-or-directory-when-performing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!