3
// 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?

bruh
  • 2,205
  • 7
  • 30
  • 42

2 Answers2

2

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.

Community
  • 1
  • 1
tadman
  • 208,517
  • 23
  • 234
  • 262
  • Thanks for the response. I was wondering whether to change the version globally, locally or shell specific. I ended up changing it globally, I was just scared to make the change before. – bruh May 02 '16 at 00:46
  • 1
    Each method is valid depending on the circumstances, that's why there's options. `global` is what you use by default, so set it to your favourite. `local` is project-specific, best used with legacy code that can't be upgraded yet. – tadman May 02 '16 at 00:47
  • This thread cleared up a lot for me. For someone who has been groping in the dark, is there a way to id which version of ruby is used locally and which is used globally? Also: Is there a "best practice" to "fix" a ruby version when one begins a new rails project? – YCode Aug 09 '18 at 21:11
  • `rbenv global` tells you the global version, `rbenv local` the local one if any such version is set. – tadman Aug 09 '18 at 21:28
1

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 :)