Install Ruby and Rails on Fedora 40

BrunoBruno
2 min read

A few weeks ago I’ve had a problem about install the Ruby on Rails development environment on Fedora 39. First I try the same tutorial that I always use to install Rails on Ubuntu/Debian and similar distros, but I’ve had some problems. If you’re using some Debian based distribution I strong recommends this article:

https://gorails.com/setup/ubuntu/22.04

But if you’re a Fedora user, and this is the reason that you stay here, let’s go! Fedora have one of the most stable and simple to use package manager among the Linux world called “dnf”, something strong like that is the Pacman for Arch Linux. Ok, let’s setup our system.

The first thing is obvious but stronger needed, update your system, so:

sudo dnf update -y

The flag “-y” is the same thing to say “Yes” to install all the packages. Now let’s install some needed packages:

sudo dnf install git curl plaintextmake automake gcc gcc-c++ kernel-devel libyaml-devel -y

Now everything in our system is ok to build and install our ruby versions! In the last two years I've been using "asdf" for multiple versions of languages like Ruby, Node and Elixir and for now I don't have any intention to change to another. To learn more about asdf:

https://asdf-vm.com/

So, now let’s install “asdf” on our system:

cd
git clone https://github.com/excid3/asdf.git ~/.asdf
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
echo 'legacy_version_file = yes' >> ~/.asdfrc
echo 'export EDITOR="code --wait"' >> ~/.bashrc
exec $SHELL

Now we need to install the Ruby asdf plugin:

asdf plugin add ruby

To install Ruby and set the default version, we’ll run the following commands:

asdf install ruby 3.3.1
asdf global ruby 3.3.1
echo "gem: --no-document" > ~/.gemrc
gem update --system

Ruby installed, let’s install rails:

gem install rails

And now everything is ok, let’s make something awesome!

rails -v

Until the future!

0
Subscribe to my newsletter

Read articles from Bruno directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Bruno
Bruno