使用bundle exec rake还是只是rake? [英] Use bundle exec rake or just rake?

查看:248
本文介绍了使用bundle exec rake还是只是rake?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仅使用rake命令(例如 rake db:migrate )来学习Rails;但是,我读到我应该使用 bundle exec rake ... 而不是普通的 Rake 。现在我对使用哪个感到困惑。

I learned Rails using just the rake command like rake db:migrate; however, I read that I should be using the bundle exec rake ... instead of just plain rake. Now I'm confused about which to use.

我应该使用 bundle exec rake 而不是普通的 rake 还是仅仅是偏好?任何见解将不胜感激!谢谢!

Should I be using bundle exec rake instead of just plain rake or is it just a preference thing? Any insight would be much appreciated! Thanks!

推荐答案

bundle exec 在您的上下文中执行命令

bundle exec executes a command in the context of your bundle.

这意味着它使用了Gemfile中指定的gem。在大多数情况下,运行 bundle exec rake foo 的结果与运行 rake foo 的结果相同,尤其是当您在系统范围内安装了与Gemfile中相同的gem。但是,某些应用程序可能指定的gem版本与您在系统范围内安装的gem版本不同,并且可能希望这些确切的gem和版本能够正确运行。如果您只是在没有 bundle exec 的情况下运行,则可能会遇到一些奇怪的错误。

That means it uses the gems specified in your Gemfile. Much of the time, running bundle exec rake foo has the same results as if you just ran rake foo, especially if you have the same gems installed systemwide as in your Gemfile. However, some applications may specify different versions of gems than the ones you have installed systemwide, and may want those exact gems and versions to be able to run correctly. If you just run without bundle exec, you may get some weird errors.

使用 bundle exec 保证程序在gemfile中指定的环境下运行,这意味着该程序的创建者希望在该环境中运行该程序,这意味着该程序应正确运行。

Using bundle exec guarantees that the program is run with the environment specified in the gemfile, which hopefully means it is the environment that the creators of the program want it to be run in, which hopefully means it should run correctly no matter what weird setup you have on your computer.

它基本上可以标准化程序的运行环境。

It basically standardizes the environment under which the program is run. This helps avoid version hell and makes life much easier.

请参见 http://bundler.io/v1.3/man/bundle-exec.1.html 了解更多信息。

这篇关于使用bundle exec rake还是只是rake?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆