简体   繁体   中英

rbenv ruby on rails global vs local vs shell

// Start background info.

I just want to install ruby on rails for development (OSX El Capitan).

Pain point:

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

Solution: Installed rbenv to manage / modify a separate ruby.

rbenv is currently using my system ruby - so I've downloaded an identical version through rbenv install.

// end background info.

Actual Question : Do I set rbenv local, global or shell ruby version to the newly downloaded version?

Usually rbenv does the dirty work for you if loaded correctly , but if you need to change the global setting, you can always update it:

rbenv global 2.3.0

Then you can check that's properly applied with:

rbenv versions

The * indicates the currently active ruby . Test with:

ruby -v

That should be the version you're asking for.

Using rbenv is a lot better than the system ruby, so I hope it works out for you.

According to the official rbenv documentation in Github, their differences are the following:

# Sets a local application-specific Ruby version
# by writing the version name to a `.ruby-version`.
$ rbenv local <version>

# Sets the global version of Ruby to be used in all shells
# by writing the version name to the `~/.rbenv/version` file
$ rbenv global <version>

# Sets a shell-specific Ruby version by setting the
# RBENV_VERSION environment variable in your shell.
# This for temporary use and will only work during the terminal session
$ rbenv shell <version>

Note that your terminal session will no longer respect any .ruby-version files. You need to run rbenv shell --unset to enable the auto switch again.

Happy Coding :)

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