DEV Community

Bruno Queiroz
Bruno Queiroz

Posted on • Updated on

Install Ruby and Rails on Fedora 40

Ruby
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
Enter fullscreen mode Exit fullscreen mode

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 automake gcc gcc-c++ kernel-devel libyaml-devel -y 
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Now we need to install the Ruby asdf plugin:

asdf plugin add ruby
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Ruby installed, let’s install rails:

gem install rails
Enter fullscreen mode Exit fullscreen mode

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

rails -v
Enter fullscreen mode Exit fullscreen mode

Until the future!

Top comments (0)