Change ruby version mac os

How to update Ruby with Homebrew?

I want to know how to update to the latest stable version of Ruby with Homebrew. I am not interested in using RVM. Thanks.

5 Answers 5

I would use ruby-build with rbenv . The following lines install Ruby 3.0.2 and set it as your default Ruby version:

brew upgrade ruby

Should pull latest version of the package and install it.

brew update updates brew itself, not packages (formulas they call it)

Adding to the selected answer (as I haven’t enough rep to add comment), one way to see the list of available versions (from ref) try:

To upgrade Ruby with rbenv: Per the rbenv README

  • Update first: brew upgrade rbenv ruby-build
  • See list of Ruby versions: versions available: rbenv install -l
  • Install: rbenv install

\curl -sSL https://get.rvm.io | bash -s stable

restart terminal then

check ruby version it should be 2.4.2

Not the answer you’re looking for? Browse other questions tagged ruby macos homebrew or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How can I switch to ruby 1.9.3 installed using Homebrew?

I have installed ruby 1.9.3 using hombrew

But default 1.8.7 is still used. How can I switch osx to use 1.9.3 as default ruby?

8 Answers 8

I suggest you take a look at rvm. You can then set it as default with rvm use 1.9.3 —default

But if you are happy with your homebrew install.

Then just change the precedence of directories in the PATH

Here is my /etc/paths

This is important generally for homebrew, else the system version of git, ruby, pg_admin. will all be used instead of the brew version.

if you say which -a ruby you’ll see all the installed rubies, and the precedence in the PATH

UPDATE: I now don’t think you should change /etc/paths

Instead you need to check which of .profile , .bashrc , or .bash_login is being loaded in your shell, and just add /usr/local/bin to your path.

Читайте также:  Windows home edition dell

For me, I only have a .profile . You can create that file if none of those files already exist in your home directory.

SHORT ANSWER:

after installing ruby via homebrew just do this:

and restart or reopen your Terminal

LONG ANSWER

So I did a normal install of ruby using homebrew

that installed fine BUT it was still using the system’s default ruby. which I verified by doing:

So as per Matthew Rudy’s suggestion, I checked the order of my /etc/paths, and all was good.

Then I decided to do:

so nothing was broken as such. tried to reinstall ruby again using the homebrew method, and then i found it.

If you’d like to use homebrew to install 1.9.3, you can follow these steps:

Once you have rbenv and ruby-build installed, you can run the following command to get Ruby 1.9.3 installed.

Now if you’d like to use 1.9.3 by default, you can run the following command:

I had similar situation. I installed ruby using Homebrew. which -a ruby gave me the following output:

Which means that newly installed version should have been used, but ruby —version still returned the old system version.

I quit terminal (Cmd+Q), and after restart ruby —version returned the correct version. So make sure you restart terminal after installing before trying any other (potentially unnecessary) fixes.

SHORT: Do note what you want to change it for.

If you’re on OS X and trying to use Ruby for something like Jekyll, then don’t use homebrew because that’s what Apple is using for Ruby for and it might not be good to use if you’re not sure what you’re doing. Instead, use rbenv or RVM.

LESS SHORT: I was trying to switch from the default version to an updated version (from 2.0) to use Jekyll because it required Ruby version 2.2.5 and above. I updated it and version 2.5 was installed, but when I checked «ruby -v», it was still 2.0. Once I finally got around to changing the default version, I wasn’t able to install the package I needed because I didn’t have write permission. For example, if you come across something like this, then you probably are having the same problem

Источник

How to update Ruby to 1.9.x on Mac?

I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? Thanks

9 Answers 9

As The Tin Man suggests (above) RVM (Ruby Version Manager) is the Standard for upgrading your Ruby installation on OSX: https://rvm.io

To get started, open a Terminal Window and issue the following command:

( you will need to trust the RVM Dev Team that the command is not malicious — if you’re a paranoid penguin like me, you can always go read the source: https://github.com/wayneeseguin/rvm ) When it’s complete you need to restart the terminal to get the rvm command working.

Читайте также:  Windows 98se что это

( shows you the latest available versions of Ruby )

For a specific version, followed by

or if you just want the latest (current) version:

( installs the current stable release — at time of writing ruby-2.3.1 — please update this wiki when new versions released )

Note on Compiling Ruby: In my case I also had to install Homebrew http://mxcl.github.com/homebrew/ to get the gems I needed (RSpec) which in turn forces you to install Xcode (if you haven’t already) https://itunes.apple.com/us/app/xcode/id497799835 AND/OR install the GCC package from: https://github.com/kennethreitz/osx-gcc-installer to avoid errors running «make«.

Edit: As of Mavericks you can choose to install only the Xcode command line tools instead of the whole Xcode package, which comes with gcc and lots of other things you might need for building packages. It can be installed by running xcode-select —install and following the on-screen prompt.

Note on erros: if you get the error «RVM is not a function» while trying this command, visit: How do I change my Ruby version using RVM? for the solution.

Источник

How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite?

I need to update my ruby version from 2.0.0 to the latest version, I can not use some gems because my version is not updated. I had used Homebrew to install Ruby some time ago, How can i update my Ruby version?

11 Answers 11

Open your terminal and run

When this is complete, you need to restart your terminal for the rvm command to work.

Now, run rvm list known

This shows the list of versions of the ruby.

Now, run rvm install ruby@latest to get the latest ruby version.

If you type ruby -v in the terminal, you should see ruby X.X.X .

If it still shows you ruby 2.0. , run rvm use ruby-X.X.X —default .

Prerequisites for windows 10:

  • C compiler. You can use http://www.mingw.org/
  • make command available otherwise it will complain that «bash: make: command not found». You can install it by running mingw-get install msys-make
  • Add «C:\MinGW\msys\1.0\bin» and «C:\MinGW\bin» to your path enviroment variable

Brew only solution

Update:

From the comments (kudos to Maksim Luzik), I haven’t tested but seems like a more elegant solution:

After installing ruby through brew, run following command to update the links to the latest ruby installation: brew link —overwrite ruby

Original answer:

Late to the party, but using brew is enough. It’s not necessary to install rvm and for me it just complicated things.

By brew install ruby you’re actually installing the latest (currently v2.4.0). However, your path finds 2.0.0 first. To avoid this just change precedence (source). I did this by changing

/.profile and setting:

Читайте также:  Ffmpeg windows build mingw

After this I found that bundler gem was still using version 2.0.0, just install it again: gem install bundler

/.bash_profile» after install

rbenv does…

  • Provide support for specifying application-specific Ruby versions.
  • Let you change the global Ruby version on a per-user basis.
  • Allow you to override the Ruby version with an environment variable.

In contrast with RVM, rbenv does not…

  • Need to be loaded into your shell. Instead, rbenv’s shim approach works by adding a directory to your $PATH .
  • Override shell commands like cd or require prompt hacks. That’s dangerous and error-prone.
  • Have a configuration file. There’s nothing to configure except which version of Ruby you want to use.
  • Install Ruby. You can build and install Ruby yourself, or use ruby-build to automate the process.
  • Manage gemsets.Bundler is a better way to manage application dependencies. If you have projects that are not yet using Bundler you can install the rbenv-gemset plugin.
  • Require changes to Ruby libraries for compatibility. The simplicity of rbenv means as long as it’s in your $PATH , nothingelse needs to know about it.

INSTALLATION

Install Homebrew http://brew.sh

UPDATE
There’s one additional step after brew install rbenv Run rbenv init and add one line to .bash_profile as it states. After that reopen your terminal window […] SGI Sep 30 at 12:01 —https://stackoverflow.com/users/119770

Set the global version:

Set the local version of your repo by adding .ruby-version to your repo’s root dir:

Источник

Update Ruby to Latest Version on Mac OS X

I recently needed to do a small scripting job in Ruby, and to use the gems required I needed to be on the latest version of Ruby (2.4.1). My MacBook was on an older version, so I needed to run a quick update. Here is the process I followed:

1. Check the version of Ruby installed on your Mac

Open terminal and type:

2. Install the Ruby Version Manager rvm

In terminal, curl -L https://get.rvm.io | bash -s stable

Once this command has finished running you may need to restart your terminal for rvm to be recognised.

3. Install the latest version of Ruby

rvm install ruby-[version]

In my case this was

rvm install ruby-2.4.1

This took a while to run as it had to install a lot of dependencies and asked for my permission a couple of times.

4. Set the latest version of Ruby as the one you want to use

You should now be running the latest version of Ruby. You can check as before with the ruby -v command as in step 1. If you’re find that you’re not, you can set this manually. In terminal type:

rvm use ruby-2.4.1

If you want to set this latest version of Ruby as the default version, in terminal type:

rvm —default use 2.4.1

Don’t forget to replace 2.4.1 with the version number of your latest Ruby.

Источник

Оцените статью