I want to know how to update to the latest stable version of Ruby with Homebrew. I am not interested in using RVM. Thanks.
Asked
Active
Viewed 1.3e+01k times
90
-
1Are you against RVM or version managers in general? If you don't have old rubies installed, you won't be able to run older Ruby libraries on your computer. Rbenv can be frendlier. I'm not even sure the latest Ruby versions are pushed to system package managers like Homebrew. On ubuntu, the default Ruby version is still 1.9.3 – max pleaner Apr 08 '16 at 02:36
5 Answers
182
I would use ruby-build with rbenv. The following lines install Ruby 3.1.2 and set it as your default Ruby version:
$ brew update
$ brew install ruby-build
$ brew install rbenv
$ rbenv install 3.1.2
$ rbenv global 3.1.2
spickermann
- 89,540
- 8
- 92
- 120
-
7Is there no way to automatically update to the latest, stable version of Ruby without "hard coding" the version in there? Something like `rbenv install latest`? – Ralph David Abernathy Apr 07 '16 at 19:40
-
2I prefer to have more control over the version, but you might want to use this example: http://stackoverflow.com/a/30191850/2483313 – spickermann Apr 07 '16 at 19:46
-
3Thanx for the answer. I had to run this as well: echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile – guya Sep 10 '16 at 23:54
-
1Thank you! I then had to run `gem install rails` to get rails and it was all working – svnm Feb 02 '17 at 00:03
-
10The rbenv install felt like it was stuck so if you want to make sure some progress is being made run: `$ rbenv install --verbose 2.4.0` – Vigrant Mar 07 '17 at 20:17
-
5Ok, that worked well, but then how do you update your system to use the homebrew version rather than the default one? – chrismarx Apr 28 '17 at 18:58
-
-
2Yeah, see this thread, but basically, you need "eval "$(rbenv init -)" in your ~/.bash_profile - https://github.com/rbenv/rbenv/issues/815 – chrismarx Jan 29 '18 at 15:16
-
if you have a .ruby-version file in your project directory or from wherever you are calling the ruby command, you still need to update that with `rbenv local 2.6.1` otherwise it will override the global setting – bryant Mar 11 '19 at 23:56
-
you do not need this `brew install ruby-build` as it is installed as a dependency when you are installing rbenv. – stan Dec 14 '19 at 01:35
-
Also you have to add this: `eval "$(rbenv init -)"` to your .bash_profile or .zshrc, whatever you are using, so that you point to the above version of ruby and not the system one. – stan Dec 14 '19 at 01:41
88
brew upgrade ruby
Should pull latest version of the package and install it.
brew update updates brew itself, not packages (formulas they call it)
Gustavo Rubio
- 9,431
- 6
- 37
- 57
10
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 <selected version>
ltrainpr
- 2,737
- 3
- 27
- 40
-4
open terminal
\curl -sSL https://get.rvm.io | bash -s stable
restart terminal then
rvm install ruby-2.4.2
check ruby version it should be 2.4.2
Devesh
- 865
- 9
- 10