heroku: bash: bundle: command not found

2019-02-22 07:56发布

问题:

I am porting a Heroku app from Aspen to Cedar stack at Heroku, following their instructions.

I'm at the last deploy step. I get this error:

    2012-10-22T11:23:53+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -p 40310 -e production`
2012-10-22T11:23:54+00:00 app[web.1]: bash: bundle: command not found

I can't see how I can be responsible for telling the Heroku stack where bundle is, or providing it, since bundler is used by it for exactly this job. This command is specified in the Procfile for the app:

web: bundle exec thin start -p $PORT -e $RACK_ENV

Another similar question on stackoverflow suggests that this happens if the app is pushed to Heroku without a Procfile initially, so Heroku gets the wrong idea about what kind of app it is. That poster deleted his app and created a new one and reported success. However, the effort involved in deleting and recreating my ported app is high. Is there some way I can fix this rather than start over?

回答1:

Heroku's slug build process must have changed with regard to ruby 1.8.7 apps. I'm guessing they started bundling to 1.8 paths instead of 1.9.1 for 1.8 apps. My previously working app stopped working after I tried to push a new revision.

Here's what got it working again:

heroku config:add PATH=bin:vendor/bundle/1.8/bin:/usr/local/bin:/usr/bin:/bin GEM_PATH=vendor/bundle/1.8

I took these paths from a newly created app using the same git repository as I used before.

EDIT: Turns out that heroku published a devcenter article Changing Ruby Version Breaks Path that specifies paths for various ruby versions.



回答2:

I had the same issue and I solved it by setting the correct heroku config variables

$ heroku config
=== xxxx Config Vars
DATABASE_URL:                  postgres://(...)
GEM_PATH:                      vendor/bundle/ruby/1.9.1
HEROKU_POSTGRESQL_CRIMSON_URL: postgres://(...)
LANG:                          en_US.UTF-8
PATH:                          bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
PGBACKUPS_URL:                 https://(...)
RACK_ENV:                      production
RAILS_ENV:                     production

you can create an empty rails app, push it to heroku and check the variables it automatically set, then copy (and adapt) them to your application