Rails 3 - Whenever a gem: / usr / bin / env: ruby: error is missing such a file or directory

When using "all gem" I get an error message in the log:

/usr/bin/env: ruby: No such file or directory 

It works when I run the task manually. I installed everything using RVM.

I used the which command to find where my Ruby installation is, and I get:

 kevin@lovely :/opt/personal$ which ruby /home/kevin/.rvm/rubies/ruby-1.9.2-p290/bin/ruby 

and I checked the $ PATH variable where it returns:

 kevin@lovely :/opt/personal$ echo $PATH /home/kevin/.rvm/gems/ruby-1.9.2-p290/bin:/home/kevin/.rvm/gems/ ruby-1.9.2-p290@global /bin:/home/kevin/.rvm/rubies/ruby-1.9.2-p290/bin:/home/kevin/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 

I believe this should be set up correctly, but I am probably mistaken, as this does not work. Can someone point me in the right direction?

If you're interested, this is what mine every time the crontab output:

 # Begin Whenever generated tasks for: rss 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /opt/personal && script/rails runner -e development '\''FeedEntry.update_from_feed("http://lovely/blog/feed/")'\'' >> /opt/personal/log/feedzirra.log 2>&1' 
+7
source share
5 answers

You probably passed this problem long ago, but for future reference:

I had a similar problem, only I was getting

 /usr/bin/env: ruby: No such file or directory 

It turned out that the first line of the script \ rails file was #!/usr/bin/env ruby1.9.1 , which tells the system to call it with ruby1.9.1, as described here , but it should have been #!/usr/bin/env ruby1.9.3 since it was the version I installed.

Hope this helps someone in the future :)

+6
source

My problem was that ruby ​​is located in / usr / local / bin, which is not in the headless bash path. So I just made my rake line in schedule.rb:

 job_type :rake, "cd :path && PATH=/usr/local/bin:$PATH RAILS_ENV=:environment bundle exec rake :task :output" 
+4
source

If none of them worked for you, try:

 gem install rails 

It helped me, hope it helps!

+2
source

I use it successfully whenever RVM and bundler are produced. Here are the relevant snippets of my capistrano setup that may help you:

 # rvm and bundler integration require 'rvm/capistrano' require 'bundler/capistrano' # RVM environment set :rvm_ruby_string, " ruby-1.9.2@mygemset " # crontab set :whenever_roles, :cron set :whenever_command, "bundle exec whenever" set :whenever_environment, defer { stage } require 'whenever/capistrano' 

Meaning :whenever_environment is due to the fact that I am using a multi-stage deployment setup. You can ignore this or set it to a string that matches your setting, if necessary.

Most of this information is contained whenever the github page is in the headings of the "Capistrano integration" and "RVM Integration" sections in README.

I hope this helps.

+1
source

I solved the problem in much the same way as the Duke. Also, I realized that the $ PATH variable is not working for me.

 sys_path = '/home/[user]/.rbenv/versions/[ruby_version]/bin' job_type :runner, "cd :path && PATH=#{sys_path} bin/rails runner -e :environment ':task' :output" job_type :rake, "cd :path && PATH=#{sys_path} :environment_variable=:environment bin/bundle exec rake :task --silent :output" 
0
source

All Articles