rbenv 或捆绑器 gemset 沙箱?

发布于 2024-12-27 07:07:21 字数 370 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

北城孤痞 2025-01-03 07:07:21

我找到了这个清晰、记录齐全的解决方案:

设置和安装 rbenv、ruby-build、rubies、rbenv-gemset、和捆绑器

现在,当您安装 gem(请参阅下面的“Bundler”部分)时,它将进入您的 helloset gem 区域。

您可以结合使用多个宝石集。

此设置的最大好处是使每个项目都可以使用一组不同版本的 gem。

阅读标题为启用 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

Now when you gem install (see “Bundler” section below) something it will go to your helloset gem area.

You can combine use of multiple gemsets with it.

The big benefit to this setup is enabling each project to use a different set of differently versioned gems.

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.

地狱即天堂 2025-01-03 07:07:21

从本质上讲,bundle 使用 GemfileGemfile.lock 文件为该特定项目创建一个“gemset”,您可以通过以 bundle exec 为前缀的命令访问该项目

bundler uses the Gemfile and Gemfile.lock files in, in essense, to make a "gemset" for that particular project that you access via commands prefixed with bundle exec

岁月静好 2025-01-03 07:07:21

这可能与 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

千仐 2025-01-03 07:07:21

尝试将 chgems 与 Bundler 结合使用。 chgems 类似于 RubyGems 的 chroot。它生成一个新的子 shell,其中 PATHGEM_HOMEGEM_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 and GEM_PATH updated to use $project/.gem/$ruby/$version as the primary GEM_HOME. Since all gems are installed inside of the project directory, cleaning up after a project is as easy as rm -rf $project/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文