bundle exec with heroku - is it necessary?

2019-06-22 03:07发布

I recently set up a Cedar (Rails 3.1) app on Heroku, and to run, for example, a migration, you'd do

heroku run rake db:migrate

I learned that it's good practice to use "bundle exec" before any rake command (as Katz says http://yehudakatz.com/). So, I thought perhaps the following is actually better practice:

heroku run bundle exec rake db:migrate

But to reduce verbosity, is it alright to use the former command, or is the one with bundle exec critical?

2条回答
Juvenile、少年°
2楼-- · 2019-06-22 03:39

"In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle. However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine"

Quoting from bundler's Documentation

查看更多
Fickle 薄情
3楼-- · 2019-06-22 03:40

On Heroku when the slug is compiled the Gems are installed from into a clean slug as specified in your Gemfile so there's not going to be extraneous Gems floating around the place - there's no need to use bundle exec on Heroku - else I'm sure the Heroku documentation would tell you to do it.

查看更多
登录 后发表回答