I saw the following questions here:
However, none of these helped me.
How can I define the correct rake to use in tasks on capistrano while using rvm? The code is simple:
task :precompile_production_assets do
on roles(:all) do |host|
execute("cd #{fetch(:deploy_to)}/current && rake -T")
end
end
This command returns me:
DEBUG [bae8f8f7] Command: cd /home/rails/current && rake -T
DEBUG [bae8f8f7] bash: /usr/local/bin/rake: /usr/bin/ruby1.8: bad interpreter: No such file or directory
My setup and some gems are:
It seems like rake is being called from a different place but I don't know how to fix it.
On deploy.rb I set up set :rvm_ruby_version, '2.2.0project'
as told in https://github.com/capistrano/rvm/ and on my Capfile I commented out
require 'capistrano/rvm'
require 'capistrano/bundler'
execute("cd #{fetch(:deploy_to)}/current && rake -T")
execute("cd #{fetch(:deploy_to)}/current && bundle exec rake -T")
returns me :
DEBUG [bae8f8f7] bash: /usr/local/bin/rake: /usr/bin/ruby1.8: bad interpreter: No such file or directory
execute(:rake, 'assets:precompile', 'RAILS_ENV=production')
returns me :
DEBUG [b4457b08] Command: /usr/local/rvm/bin/rvm 2.2.0@project do bundle exec rake assets:precompile RAILS_ENV=production
DEBUG [b4457b08] Could not locate Gemfile or .bundle/ directory
In this mode rake is ok but is being executed in another place and I want it on /home/rails/current. With this different syntax I don't know how to cd location && rake sometask
I wanted to post this as a comment, but I can only post as an answer due to my low reputation. Also, my formatting isn't applied for some reason.
in deploy.rb do you really have:
set :rvm_ruby_version, '2.2.0project'
Or did you type that wrong here and have it correct in deploy.rb as:
set :rvm_ruby_version, '2.2.0@project'
Without seeing the contents of your deploy.rb file or knowing your system configuration, I can only provide the following possible fixes:
If all else fails, you could always try:
set :rvm_custom_path '~/your/ruby/path'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.