简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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