How to use rbenv and store gems locally - coming from rvm background

让人想犯罪 __ 提交于 2020-07-10 06:54:25

问题


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

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.

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

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.

Update

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


回答1:


Here's what I recommend:

  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)
  2. Use bundler to dynamically resolve gems at runtime (options below)
    • it's fast enough anyways
    • don't need a special gem solution, bundler comes included /w Ruby now

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

  1. use bundle exec in front of every ruby executable
    • variant: create alias be='bundle exec'
  2. create bundle binstubs <LIST GEM EXECUTABLES YOU WANT> for each project
    • use bin/ in front of every ruby executable to call the binstubs
  3. do #2 and then set up .git/safe
    • lets you manually allow PATH lookups to the bin/ folder while in that project root
    • don't need to type bin/ anymore

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.



来源:https://stackoverflow.com/questions/62732063/how-to-use-rbenv-and-store-gems-locally-coming-from-rvm-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!