where is ruby 3.0.0 on rbenv - ruby

rbenv install --list-all shows me, among many other things of course,
3.0.0-dev
3.0.0-preview1
3.0.0-preview2
But where is 3.0.0 itself, the actual final release? I'd like to try it out. Not all announced features made it into the previews so I need the real thing.

rbenv install passes thru ruby-build. You need to update (brew upgrade if installed via Homebrew) your ruby-build in order to see the latest versions.

On Ubuntu
Short answer:
# You need to update the available versions via ruby-build
~ git -C ~/.rbenv/plugins/ruby-build pull
~ rbenv install 3.0.0
...
Installed ruby-3.0.0 to ~/.rbenv/versions/3.0.0
Long answer with a beautiful picturešŸˆ: https://richstone.io/where-is-ruby-3-0-0-on-rbenv/

Ubuntu
git -C ~/.rbenv/plugins/ruby-build pull (pulls latest ruby versions)
rbenv install 3.0.0 (or for later versions: 3.x.x)
echo "3.0.0" > .ruby-version OR rbenv local 3.0.0 to ensure ruby 3.0.0 is used.
Mac
brew upgrade

Related

How to manage ruby version installed without rbenv in rbenv?

I had problems installing ruby with rbenv so I installed it with Homebrew.
The problem is that I still want to manage this ruby version with rbenv.
How can I do that?
Let's say you installed ruby 2.7 (brew does not let you choose patch version): brew install ruby#2.7.
We will call this version 2.7-brew in rbenv but you can call it whatever you like (for example 2.7). Just change all pathes in this answer from 2.7-brew to 2.7 or to another name.
We want rbenv to manage this ruby version:
cd ~/.rbenv/versions
mkdir -p 2.7-brew/bin
We need to link our newly installed ruby version:
replace <Installed Version> with the version brew installed (probably 2.7.7 or a greater patch version)
If you donā€™t know the version or the installation directory run:
brew info ruby#2.7
Link this ruby version to the directory we have created:
On Mac computers with apple silicon (M1).
ln -s /opt/homebrew/Cellar/ruby#2.7/<Installed Version>/bin/ruby 2.7-brew/bin/ruby
On Mac computers with amd64 architecture (Intell).
ln -s /usr/local/Cellar/ruby#2.7/<Installed Version>/bin/ruby 2.7-brew/bin/ruby
Let rbenv know that we added a new ruby version:
rbenv rehash
Now, rbenv should be able to use this new ruby version.

Need help installing Ruby 2.7.2 on Mac

I'm trying to install Ruby version 2.7.2 on my Mac (latest OS with all updates) and did the following
brew update
brew upgrade rbenv ruby-build
and then
rbenv install 2.7.2
ruby-build: definition not found: 2.7.2
See all available versions with `rbenv install --list'.
If the version you need is missing, try upgrading ruby-build:
brew update && brew upgrade ruby-build
So I tried following the instructions above and get this
brew update && brew upgrade ruby-build
Already up-to-date.
Warning: ruby-build 20200926 already installed
You need to install the latest ruby-build
$ brew unlink ruby-build # remove STABLE version
$ brew install --HEAD ruby-build
$ rbenv install -l | grep '2.7.2'
2.7.2
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.
The answer from #andrei-kovrov is correct but, alternatively, you can wait until this PR gets merged:
https://github.com/Homebrew/homebrew-core/pull/62096
Btw, this answer will not age well so, for reference, this is where the formulae are staged before they get released:
https://github.com/Homebrew/homebrew-core/pulls
It might be an issue reading the correct version of ruby based on the path that is specified. If you already have another version of ruby installed the path might not be updated to look for a newer version.
This article has a lot of really great information on how to set up ruby on a mac:
https://stackify.com/install-ruby-on-your-mac-everything-you-need-to-get-going/

Ruby version not in ruby-build list for rbenv

I'm using Rails 4.2 and wanted to update my Ruby version as well with rbenv.
I used Homebrew to install ruby-build and no matter how many times I try to update via brew, Ruby version 2.1.3 won't show when I run rbenv install --list.
Usually, follow these steps to install a new Ruby version with rbenv:
$ brew update
$ brew upgrade ruby-build
$ brew upgrade rbenv
Check which versions are available after updating:
$ ruby-build --definitions
Install a specific version (for example 2.1.3) with:
$ rbenv install 2.1.3
Or if you are interested into improved support for UTF8 characters in the irb console:
$ RUBY_CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.1.3
After these steps I usually set the newest version as my global default:
$ rbenv global 2.1.3
If you installed rbenv and ruby-build with homebrew and when you do echo $(rbenv root), you get /usr/local/var/rbenv instead of /Users/<username>/.rbenv, here is how to fix the issue.
When you install rbenv with homebrew, homebrew says:
To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=/usr/local/var/rbenv
Don't do that. Remove that line from your profile. Make sure you refresh your terminal after.
Then remove any signs of rbenv in the /usr/local/var directory:
sudo rm -r /usr/local/var/rbenv
Now when I do echo $(rbenv root) I get /Users/<username>/.rbenv instead of /usr/local/var/rbenv.
That fixed it for me.
The recommended installation from (https://github.com/sstephenson/ruby-build) states that you should install ruby-build as an rbenv plug-in.
I uninstalled ruby-build via Homebrew (brew uninstall ruby-build)
Navigated to ruby-build on my local machine and deleted it
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Now, when I run rbenv install --list, I see Ruby 2.1.3. A quick installation of: rbenv install 2.1.3 and I am now free to use 2.1.3 where I like. This also worked for my teammate.
Please update by brew upgrade ruby-build and then you should see 2.1.3 in rbenv install --list
You need to update ruby build. After update you can install all current suported versions.
If you using rbenv installed via git use
cd "$(rbenv root)"/plugins/ruby-build && git pull
Or via home brew
$ brew upgrade ruby-build
$ brew upgrade rbenv

Force rbenv to install openssl?

I have an existing version of openssl installed, however its the old version. Upgrading to new releases of Ruby, using rbenv, does not upgrade openssl.
How do I force rbenv to upgrade?
This is under ubuntu 10.
rbenv is not a package manager. This is a good thing.
If you want to use a newer version of openssl, simply specify it when you compile ruby
$ ./configure --prefix=$HOME/.rbenv/versions/2.0.0-p247 --with-opt-dir=/usr/local/opt/openssl --enable-shared
To see more help, use $ ./configure --help
If you're using rbenv ruby-build plugin, you can use CONFIGURE_OPTS
$ CONFIGURE_OPTS="--with-opt-dir=/usr/local/opt/openssl" rbenv install 2.0.0-p247
Read more about Special Environment Variables for ruby-build

rbenv not showing the available ruby versions

I have installed rbenv in my vagrant machine but when I try to list all the available ruby versions rbenv versions then it gives me this output:
system (set by /home/vagrant/.rbenv/version)
Does anyone know what is this?
Are you asking what the output of that command means? I'm looking at the rbenv documentation, and I think it indicates that rbenv only knows of one version of ruby - the version that came installed with your system.
Edit: If that's not the answer you were looking for, can you tell us what you expected to see? Did you have other versions installed on that machine?
Edit 2: If you want to see a list of versions you can install onto your machine, but aren't installed yet, run:
rbenv install --list
Here is more documentation for this command. This will help!
If you have tried both rbenv install --list and ruby-build --definitions and still can't see the latest Ruby versions on the list, then you need to upgrade ruby-build because that is what rbenv uses to "know" the available versions.
For example, assuming you use Mac OS X and installed ruby-build using Homebrew, you can update ruby-build by invoking:
brew upgrade ruby-build
Now, try listing the available versions again, and you should see the latest ones there.
Edit:
The ruby-build wiki lists a couple of ways of updating it, namely the above one using Homebrew and another one where it is installed as a plugin to rbenv:
cd "$(rbenv root)"/plugins/ruby-build && git pull
Rbenv is usually installed with it's companion ruby-build
You can get the versions available to be installed with:
ruby-build --definitions
To get a list of available ruby versions you can install, type the following:
rbenv install -l
To get a list of the ruby versions already installed on your machine, type the following:
rbenv versions
To answer your question as to what the below means:
system (set by /home/vagrant/.rbenv/version)
This is telling you that the system ruby (the default ruby installed on your system) is the only ruby version installed on your vagrant machine. Rbenv is using the default system ruby because it doesn't have any other ruby versions installed yet.
To see all available versions:
rbenv install --list-all
Or
rbenv install --list
To list only stable releases for each Ruby implementation.
If you are on Mac
brew upgrade rbenv ruby-build also works.
Documentation
List rbenv versions that are possible to install
"Only latest stable releases for each Ruby implementation are shown.
With the fewest key strokes (shorter than --list and --list-all)
rbenv install -l
Want to see what is available from rbenv to install?
ruby-build --definitions
Want to narrow that down a bit?
ruby-build --definitions | grep 3.0
To upgrade to the latest rbenv and update ruby-build with newly released Ruby versions, upgrade the Homebrew packages:
brew update && brew upgrade rbenv ruby-build
Also you can always just type rbenv
Which will give you a help menu
rbenv
TLDR the manpage or github repo or just plain forgot?
Take a peek at this site for quick rbenv recollection:
https://devhints.io/rbenv
Also, you may need to brew upgrade if you have installed with brew see here.

Resources