保存安装宝石的不同方式的位置?
以下命令的保存位置有什么不同吗?:
gem install some_gem
sudo gem install some_gem
bundle install
bundle install
适用于 Rails 3 项目。
都是将安装的gem保存在同一个目录还是不同目录?
Are there any differences in the save locations for the following commands?:
gem install some_gem
sudo gem install some_gem
bundle install
bundle install
is for rails 3 project.
Will all of them save the installed gem in the same directory or in different directories?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能在不同的目录中,因为“root”用户具有与您不同的帐户和路径。
通过
sudo
进行 root 访问将允许将文件写入/usr/bin
或/usr/local/bin
中 Ruby 的 gem 环境代码> 目录。 (Gem 不会将文件放在那里,但它们会与这些目录之一中的 Ruby 相关联。)默认情况下,您无权写入这些区域,因此如果您尝试运行 gem安装,并且只有系统 Ruby,您可能会收到权限错误,并且尝试应该失败。
Probably in different directories, because the "root" user has a different account and path than you do.
Root's access via
sudo
will allow the file to be written to the gem environment for a Ruby in the/usr/bin
or/usr/local/bin
directories. (Gem won't put the files there, but they'll be associated with a Ruby in one of those directories.)You don't have access to write to those areas by default, so if you tried to run
gem install
, and only had a System Ruby, you'd probably get permission errors and the attempt should fail.铁皮人回答了
sudo
与非sudo
,因此对于捆绑程序...Bundler 将 gems 安装到系统路径(类似于它们是由
sudo 安装的) code>sudo
)——至少在 OSX 上,尽管我想其他操作系统也是一样的。The Tin Man answered
sudo
vs. non-sudo
, so as for bundler...Bundler installs gems to the system path (similarly to if they'd been installed by
sudo
)--at least on OSX, though I imagine other OS would be the same.