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:
- rvm current: ruby-2.2.0@project
- rails 4.2.0
- gem capistrano 3.3.5
- gem capistrano-rvm 0.1.2
- gem capistrano-bundler 1.1.3
- gem capistrano-rails 1.1.2
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'
Tries:
1 - The commands below:
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
2 - The command below
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
rake bad interpreter: No such file or directory
I got many results, including this stackoverflow.com/questions/7907055/… no idea if this particular question solves your problem - but you should really try the above google search and read through the results. – Taryn East