Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemfile not found when running Cron job with Capistrano 3 and whenever gem #555

Closed
Set2005 opened this issue May 5, 2015 · 5 comments
Closed

Comments

@Set2005
Copy link

Set2005 commented May 5, 2015

My cron job works fine on my local machine after running whenever -w, after deploy to my VPS, I get this error, release 20150415044915 doesn't exist. any idea?

I looked at my crontab -e, the path also looks fine where 20150502114703 is the correct release:

0 1 * * 1 /bin/bash -l -c 'cd /home/hey_production/releases/20150502114703 && bin/rails runner ....

Error Log:

/usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/definition.rb:22:in `build': /home/hey_production/releases/20150415044915/Gemfile not found (Bundler::GemfileNotFound)
  from /usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler.rb:154:in `definition'
  from /usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler.rb:117:in `setup'
  from /usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/setup.rb:17:in `<top (required)>'
  from /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
  from /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
  from /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
  from bin/rails:14:in `<main>' 
@Set2005
Copy link
Author

Set2005 commented May 5, 2015

How do I setup BUNDLE_GEMFILE in my schedule.rb file?

@superbilk
Copy link

I have a similar issue since two weeks (started around May, 11th). And maybe a fix at the end of my comment.

That's one line in my crontab:

7 0 * * * /bin/bash -l -c 'cd /home/christian/apps/happinessmetric/releases/20150526195213 && bin/rails runner -e production '\''SystemMailer.delay.statistics'\'''

And if I run it in a shell:

/bin/bash -l -c 'cd /home/christian/apps/happinessmetric/releases/20150526195213 && bin/rails runner -e production '\''SystemMailer.delay.statistics'\'''

I get an error:

/home/christian/apps/happinessmetric/releases/20141222191928/Gemfile not found

The Gemfile is there, the timestamp is my current release.

So I tried to add bundle exec to bin/rails runner:

/bin/bash -l -c 'cd /home/christian/apps/happinessmetric/releases/20150526195213 && bundle exec bin/rails runner -e production '\''SystemMailer.delay.statistics'\'''

And it works (with the usual complaining from Bundler about bin stubs

Looks like your app's ./bin/rails is a stub that was generated by Bundler.

And the fix is: customize your job_type, I added this line on top of my config/schedule.rb

job_type :runner,  "cd :path && bundle exec bin/rails runner -e :environment ':task' :output"

I have no idea why it broke two weeks ago, but now it's working for me.

@superbilk
Copy link

Also have a look into that issue:
capistrano/bundler#45

I also followed this advice:
capistrano/bundler#45 (comment)

@TomNaessens
Copy link

👍 same problem, fixed it using the job_type modifier

@benlangfeld
Copy link
Collaborator

This should have been fixed by 9f37076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants