简体   繁体   English

rbenv或捆绑器gemset沙箱?

[英]rbenv or bundler gemset sandboxing?

The rbenv documentation states that you can use the gemsets plugin to sandbox your gems if you aren't using bundler: rbenv文档指出,如果不使用捆绑程序,则可以使用gemsets插件对您的gem进行沙箱处理:

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. 但是,我正在使用捆绑程序,当我在具有不同gemset的项目之间切换时,我需要重新捆绑。 When I was using rvm, this was simple due to the .gemsets file. 当我使用rvm时,由于使用了.gemsets文件,因此这很简单。

Is there a sandboxing functionality in bundler that I am not aware of or have I misunderstood the documentation? 捆绑程序中是否存在我不知道的沙箱功能,或者我误解了文档?

I found this clear, well-documented solution: 我找到了这个清晰的,有据可查的解决方案:

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler 设置并安装rbenv,ruby-build,ruby,rbenv-gemset和bundler

Now when you gem install (see “Bundler” section below) something it will go to your helloset gem area. 现在,当您安装gem(请参阅下面的“捆绑程序”部分)时,它将进入您的helloset gem区域。

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) . 阅读标题为“ Enable RVM-style “gemsets” (optional)

It uses the rbenv plugin for gemsets: https://github.com/jamis/rbenv-gemset . 它使用rbenv插件用于gemset: https : //github.com/jamis/rbenv-gemset

Update 8/12/2012 更新8/12/2012
I am using this to manage two projects with different versions of Ruby, and separate sets of gems. 我正在用它来管理两个使用不同版本的Ruby以及单独的gem的项目。 It works well. 它运作良好。

捆绑程序使用GemfileGemfile.lock文件为您通过以bundle exec Gemfile.lock命令访问的特定项目创建一个“ gemset”

Try using chgems with Bundler. 尝试将chgems与Bundler 一起使用。 chgems is like chroot for RubyGems. chgems就像RubyGems的chroot一样。 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 . 它产生了一个新的子Shell,其PATHGEM_HOMEGEM_PATH已更新为使用$project/.gem/$ruby/$version作为主要的GEM_HOME Since all gems are installed inside of the project directory, cleaning up after a project is as easy as rm -rf $project/ . 由于所有gems都安装在项目目录中,因此在项目执行后清理就像rm -rf $project/一样容易。

It may have to do with the way rbevn uses shims. 可能与rbevn使用垫片的方式有关。 You might want check out https://github.com/carsomyr/rbenv-bundler 您可能想查看https://github.com/carsomyr/rbenv-bundler

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM