rbenv 或捆绑器 gemset 沙箱?
rbenv 文档指出,如果您不使用捆绑器,则可以使用 gemsets 插件来沙箱您的 gems:
Manage gemsets. Bundler is a better way to manage application dependencies. If you have projects that are not yet using Bundler you can install the rbenv-gemset plugin.
但是,我正在使用捆绑器,当我在具有不同 gemset 的项目之间切换时,我需要重新捆绑。当我使用 rvm 时,由于 .gemsets 文件,这很简单。
捆绑程序中是否有我不知道的沙箱功能或者我误解了文档?
The rbenv documentation states that you can use the gemsets plugin to sandbox your gems if you aren't using bundler:
Manage gemsets. Bundler is a better way to manage application dependencies. If you have projects that are not yet using Bundler you can install the rbenv-gemset plugin.
However, I am using bundler and when I switch between projects that have different gemsets I need to re-bundle. When I was using rvm, this was simple due to the .gemsets file.
Is there a sandboxing functionality in bundler that I am not aware of or have I misunderstood the documentation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我找到了这个清晰、记录齐全的解决方案:
设置和安装 rbenv、ruby-build、rubies、rbenv-gemset、和捆绑器
阅读标题为
启用 RVM 样式“gemsets”(可选)
的部分。它使用 gemsets 的 rbenv 插件: https://github.com/jamis/rbenv-gemset。
更新 8/12/2012
我使用它来管理两个具有不同版本 Ruby 的项目以及单独的 gems 集。效果很好。
I found this clear, well-documented solution:
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler
Read the section entitled
Enable RVM-style “gemsets” (optional)
.It uses the rbenv plugin for gemsets: https://github.com/jamis/rbenv-gemset.
Update 8/12/2012
I am using this to manage two projects with different versions of Ruby, and separate sets of gems. It works well.
从本质上讲,bundle 使用
Gemfile
和Gemfile.lock
文件为该特定项目创建一个“gemset”,您可以通过以bundle exec 为前缀的命令访问该项目
bundler uses the
Gemfile
andGemfile.lock
files in, in essense, to make a "gemset" for that particular project that you access via commands prefixed withbundle exec
这可能与 rbevn 使用垫片的方式有关。您可能想要查看
https://github.com/carsomyr/rbenv-bundler
It may have to do with the way rbevn uses shims. You might want check out
https://github.com/carsomyr/rbenv-bundler
尝试将 chgems 与 Bundler 结合使用。 chgems 类似于 RubyGems 的 chroot。它生成一个新的子 shell,其中
PATH
、GEM_HOME
和GEM_PATH
更新为使用$project/.gem/$ruby/$ version
作为主要GEM_HOME
。由于所有 gem 都安装在项目目录内,因此项目后的清理工作就像 rm -rf $project/ 一样简单。Try using chgems with Bundler. chgems is like chroot for RubyGems. It spawns a new sub-shell with
PATH
,GEM_HOME
andGEM_PATH
updated to use$project/.gem/$ruby/$version
as the primaryGEM_HOME
. Since all gems are installed inside of the project directory, cleaning up after a project is as easy asrm -rf $project/
.