How to Install Ruby Gems on MAC

How to install gems without sudo on Mac OS X

If you can't use gem without sudo, it sounds like you haven't initialized rbenv correctly because the shims aren't available.

These steps are from the documentation. Confirm you did them ALL:

Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.

Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.

Add rbenv init to your shell to enable shims and autocompletion.

$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Same as in previous step, use ~/.bashrc on Ubuntu, or ~/.zshrc for Zsh.

Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if rbenv was set up:

$ type rbenv
#=> "rbenv is a function"

Can't install RubyGems on mac: because Objective-C garbage collection is not supported

MacRuby is a completely different (and apparently unmaintained) re-implementation of the Ruby language based on macOS primitives. Given that MacRuby was never finished and was last updated in 2012, it appears that MacRuby is not compatible with modern macOS versions anymore.

With that being said, MacRuby is different from the "default" Ruby implementation usually called MRI or just ruby. On your Mac (as well as Linux, other *nix systems or Windows), you can just use the standard Ruby just fine.

To install the latest version of Ruby using RVM, you can run

rvm install 3.0
rvm use 3.0

At the time this answer was written, this will install and activate Ruby 3.0.2 on your Mac.



Related Topics



Leave a reply



Submit