将 exec 与 heroku 捆绑在一起 - 有必要吗?
我最近在 Heroku 上设置了一个 Cedar (Rails 3.1) 应用程序,并且要运行例如迁移,我了解到
heroku run rake db:migrate
在任何 rake 命令之前使用“bundle exec”是一个很好的做法(正如 Katz 所说http://yehudakatz.com/)。所以,我认为也许以下实际上是更好的做法:
heroku run bundle exec rake db:migrate
但是为了减少冗长,可以使用前一个命令,还是使用bundle exec的命令很重要?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Heroku 上,当编译 slug 时,Gems 会按照 Gemfile 中的指定安装到一个干净的 slug 中,因此不会有无关的 Gem 漂浮在周围 - 无需在 Heroku 上使用 bundle exec - 否则我确信Heroku 文档会告诉你这样做。
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.
“在某些情况下,如果可执行文件恰好安装在您的系统中并且没有引入与您的捆绑包冲突的任何 gem,那么在没有捆绑包执行的情况下运行可执行文件可能会起作用。但是,这是不可靠的,并且是相当大的痛苦的根源。即使如果它看起来有效,则它可能在将来或在另一台机器上不起作用”
引用自捆绑程序的文档
"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