whenever: bundle: command not found

env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']

I found a lot of issues solved environment problem like bundle: command not found using the solutions above.

I don’t know why it works. Does it means that whenever do not load environment variable by default? env :FOO, ENV['FOO'] seems not smart, I wonder if such feature can be built in the gem?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 22 (5 by maintainers)

Most upvoted comments

If U want,I think U can edit crontab directly with crontab -e. See the $PATH ,$GEM_PATH with echo $PATH,echo $GEM_PATH.

Wow.

Just to make things clear, it is plain Ubuntu, I’m not using any ruby version manager and Ruby is installed from the packages.

Whenever includes bundler support in default configuration so it generates following crontab entry:

# Begin Whenever generated tasks for: project
0 0 * * * /bin/bash -l -c 'cd /home/user/project/releases/20141113151148 && RAILS_ENV=production bundle exec rake cron:task --silent'
# End Whenever generated tasks for: project

So far, it is just plain ubuntu, plain ruby, nothing but whenever executed inside bundler, ok?

And it does not work. Because cron is executed with PATH=/usr/bin:/bin and installed gems are in /usr/local/bin/. So it fails. bash --login is useless because the PATH stays the same.

Do you really want to claim, that this is not broken default behaviour?

To make it work you just have to change your crontab to include PATH or you have to set the env in whenever.

That entirely depends on your environment. Not everyone is using a Ruby version manager or Bundler, but even most who do don’t have this issue. The fact that your machine is configured in such a way that it can’t find Bundler is certainly not an issue with Whenever.

How about adding /usr/local/bin/ to your PATH in .bash_profile?

To be clear, this is not an issue with Whenever. Whenever’s job is to write crontab entries and it is succeeding in doing so. You would be running into the same class of issues had you crafted the entries by hand.