MAC OS RUBY UPDATE INSTALL
I updated brew and used it to install rbenv and ruby-build. Unfortunately, following the usual setup instructions didn’t really work, so I’m sharing the setup that worked for me here. Instead, I like to have multiple versions through an environment management system such as rbenv or asdf.įor this particular machine, I picked rbenv. You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.Īt this point, you might be tempted to simply sudo it, but that’s not a smart approach. If you try it with the default system installation of Ruby, you’ll get a permission error: $ gem install htmlbeautifierĮRROR: While executing gem. I needed to install htmlbeautifier, a gem used by some prettifier extensions within Visual Studio Code. You can, of course, change it back to Bash, but I don’t mind Zsh (or Fish) so I decided to keep it. One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). It’s not a polished product yet, but overall it’s been a fairly enjoyable operating system.
MAC OS RUBY UPDATE MAC
Once you are working in a newer ruby environment, you may need to check the gems and other libraries in a project that was started with an earlier version, to ensure they are compatible or need an update.Recently, I updated my Mac to the latest beta of macOS. ruby-version file set and what the value of the RBENV_VERSION environment variable is ( echo $RBENV_VERSION).
![mac os ruby update mac os ruby update](https://i.stack.imgur.com/Nkoxd.png)
2.0.0 the MacOS default), be sure to close the Terminal and start fresh with a completely terminal window/session, and take note if your working folder has a. 2.4.0) and find an older one instead (e.g. If you don’t see your desired ruby version number in the command’s output (e.g. You can confirm the ruby version in play with the command: ruby -v Your current Terminal session and any other sessions will be affected. ruby-version file or if the RBENV_VERSION environment variable is set). Rbenv global 2.4.0 changes your default ruby to the specified version in all cases where a version is not specified (e.g. ruby-version file into your project’s revision control. This is useful for project folders, and you can check the. ruby-version file in your current directory such that any time ruby is invoked from that directory (or a subtree), rbenv will select the version of ruby that you specified.
![mac os ruby update mac os ruby update](https://img.wonderhowto.com/img/48/11/63612315487366/0/mac-for-hackers-install-rvm-maintain-ruby-environments-macos.w1456.jpg)
This command works by setting the RBENV_VERSION environment variable in your session. ruby-version file in your current working directory. Rbenv shell 2.4.0 temporarily changes the ruby version in your current shell and forces its use over other versions that might be specified by a. Rbenv gives you options when choosing which version of ruby you’d like to use: Now you can install any ruby version that you like. Next, close and re-open your Terminal app to ensure that rbenv is initialized from your updated bash profile.
![mac os ruby update mac os ruby update](https://uploads.sitepoint.com/wp-content/uploads/2021/07/1625556633install-ruby-mac.png)
Install rbenv and ruby-build with brew: brew install rbenv ruby-buildĪdd rbenv to your bash profile so that it loads every time you open the Terminal app: echo 'if which rbenv > /dev/null then eval "$(rbenv init -)" fi' > ~/.bash_profile Overall, rbenv has a lighter touch on the MacOS system, and so is the preferred choice for this guide. Rvm is another tool that, similar to rbenv, can be used to switch between multiple versions of ruby. The current stable version at the time of this post is 2.4.x. Earlier OSX variants, specifically the “cats” (Mountain Lion, Lion, Snow Leopard), ship with Ruby 1.8.7.
MAC OS RUBY UPDATE MAC OSX
Later versions of Mac OSX through to MacOS Sierra include Ruby 2.0. This guide covers using the brew package manager to install rbenv on MacOS to enable you to install multiple versions of ruby and switch between them.Īpple bundles ruby with its operating system but the version is generally outdated and often unsuitable for developers working on their latest project.