07-18-2023, 11:01 PM
Try [nathanwhy's answer][user-install] before using my original answer below. His recommendation of `--user-install` should accomplish the same purpose without having to muck with your `.bash_profile` or determine your Ruby version.
----
If you are not concerned about a specific ruby version, you can skip the [heavy-lift Ruby environment manager options][heavy], and just add these lines to `~/.bash_profile`:
``` sh
export GEM_HOME="$HOME/.gem/ruby/2.0.0"
export GEM_PATH="$HOME/.gem/ruby/2.0.0"
```
The path is stolen from the original output of `gem env`:
``` yaml
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/.../2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-14
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/mylogin/.gem/ruby/2.0.0 # <---- This line, right here. -----
- /System/Library/.../usr/lib/ruby/gems/2.0.0
...
```
No `sudo`ing is required, and you can use the already-installed Ruby, courtesy of Apple.
[heavy]:
----
If you are not concerned about a specific ruby version, you can skip the [heavy-lift Ruby environment manager options][heavy], and just add these lines to `~/.bash_profile`:
``` sh
export GEM_HOME="$HOME/.gem/ruby/2.0.0"
export GEM_PATH="$HOME/.gem/ruby/2.0.0"
```
The path is stolen from the original output of `gem env`:
``` yaml
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/.../2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-14
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/mylogin/.gem/ruby/2.0.0 # <---- This line, right here. -----
- /System/Library/.../usr/lib/ruby/gems/2.0.0
...
```
No `sudo`ing is required, and you can use the already-installed Ruby, courtesy of Apple.
[heavy]:
[To see links please register here]
[user-install]:[To see links please register here]