如何在本地使用 rbenv 和存储 gems - 来自 rvm 背景 [英] How to use rbenv and store gems locally - coming from rvm background

查看:45
本文介绍了如何在本地使用 rbenv 和存储 gems - 来自 rvm 背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用 rvm,我想开始尝试 rbenv.

I used to use rvm and I want to start trying out rbenv.

据我所知,rbenv 并没有内置与 gem 相同的隔离,它只管理您的 ruby​​ 版本.

From what I understand, rbenv does not have the same isolation built in when it comes to gems, it is only managing your ruby versions.

我知道有一个处理 gem 的 rbenv 插件,但我不需要让它正确?

I know there is a rbenv addon that handles gems, but I dont' NEED to get it correct?

我仍然可以在本地将 gems 下载到我的项目中并为每个命令使用 bundle exec?

I can still download gems locally to my project and use bundle exec for each command?

有没有什么捷径可以让我在输入命令时不必如此冗长?

Is there a short cut that I don't have to be so verbose when typing my commands?

请解释工作流程,因为我不想假设任何事情.

Please explain the workflow as I dont' want to assume anything.

更新

我很困惑如何将 gem 加载到单独的文件夹中.

I'm confused how to get the gems loaded into a separate folder.

推荐答案

以下是我的建议:

  1. 使用 rbenv 进行多个 Ruby 版本管理,无需自定义
    • ruby 安装程序插件现在包含在 rbenv 中
    • 它还可以自动处理 ruby​​ 可执行文件,不再需要 rbenv rehash
    • 加载速度非常快(rvm 在 shell 启动时加载时间很长)
  1. Use rbenv for multiple Ruby version management, no customizations needed
    • a ruby installer plugin is now included with rbenv
    • it also handles ruby executable shims automatically, don't need to rbenv rehash anymore
    • it loads really fast (rvm has a noticable load time on shell startup)
  • 反正已经够快了
  • 不需要特殊的 gem 解决方案,bundler 现在包含/w Ruby

动态调用 bundler 的选项(我推荐最后一个):

Options to invoke bundler dynamically (I recommend the last one):

  1. 在每个 ruby​​ 可执行文件前使用 bundle exec
    • 变体:创建 alias be='bundle exec'
  • 在每个 ruby​​ 可执行文件前使用 bin/ 来调用 binstubs
  • use bin/ in front of every ruby executable to call the binstubs
  • 允许您在该项目根目录中手动允许对 bin/ 文件夹的 PATH 查找
  • 不再需要输入bin/
  • lets you manually allow PATH lookups to the bin/ folder while in that project root
  • don't need to type bin/ anymore

现在多个 gem 版本将全部安装到同一个 Ruby 版本存储桶中,并且您让 bundler 在每次启动之前动态地将正确的版本添加到加载路径中.

Now multiple gem versions will all be installed into the same Ruby version bucket, and you let bundler dynamically add the right versions to the load path before every startup.

这篇关于如何在本地使用 rbenv 和存储 gems - 来自 rvm 背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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