问题
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:
- 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)
- 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):
- use
bundle exec
in front of every ruby executable- variant: create
alias be='bundle exec'
- variant: create
- create
bundle binstubs <LIST GEM EXECUTABLES YOU WANT>
for each project- use
bin/
in front of every ruby executable to call the binstubs
- use
- 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
- lets you manually allow PATH lookups to the
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