为什么要使用 bundle exec <command>而不是只运行命令? [英] Why should I use bundle exec &lt;command&gt; instead of just running the command?

查看:64
本文介绍了为什么要使用 bundle exec <command>而不是只运行命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 bundle exec 而不仅仅是命令来运行可执行文件是众所周知的最佳实践.但似乎没有人能解释为什么通过 bundle exec 运行可执行文件更好.所以我问你为什么,...?

Its a well known best practice to use run executables using bundle exec <command> and not just the command. But it seems like nobody could explain why its better to run executebles via bundle exec. So I ask yo why,...?

推荐答案

如果您使用的是 bundle exec 而不是仅仅执行命令,bundler 会对您的环境变量进行一些更改,因此您可以成功访问 Gemfile 中列出的所有 gem.你可以看到 http://gembundler.com/man/bundle-exec.1.html .此外,bundler 可以将 gem 安装到自定义路径而不是系统位置,然后如果您使用 bundle execrequire 仍然可以访问它们.另请参阅 http://gembundler.com/man/bundle-install.1.html

If you are using bundle exec instead of just executing command, bundler makes some changes to your environment variable, so all gems listed in your Gemfile can be accessed successfully. You can see http://gembundler.com/man/bundle-exec.1.html . Also, bundler can install gems into custom path instead of system location and then they still will be accessible for require if you are using bundle exec. See also http://gembundler.com/man/bundle-install.1.html

所以一般的答案是:将您的 gems 集与系统 gems 隔离,并在自定义 gem 位置的情况下使它们可用于您的应用程序.

So in general answer is: to isolate your set of gems from system gems and to make them available for you application in case of custom gem location.

这篇关于为什么要使用 bundle exec <command>而不是只运行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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