Hi
This post is for the developers that want to use ruby the snap version .
Lets start
Step 1.0: Delete the old Install
If you have tried to install Ruby the snap packaged version and faced problems using gems in VSCode or what ever then you need to remove them
Do this to remove Ruby ->
snap remove ruby
or
just remove Ruby using the snap store (app center) , then go and delete the .gem folder , you'll find the .gem folder in the home folder and it's hidden by default
you should have ruby uninstalled and deleted .gems folder
Step 1.1 : Installing Ruby 🙂
Install ruby
There is two ways to install it
- using snap store (app center)
- using the terminal
sudo snap intall ruby --classic
The --classic
flag is used because Ruby requires classic confinement to access certain system resources.
Step 2: Verify the Installation
After the installation is complete, you can verify that Ruby is installed correctly by checking its version:
ruby --version
Step 3: Set Up the PATH
You need to add the Snap binary directory to your PATH. I don't what is this but you can do it by editing your .bashrc
file.
- Open your
.bashrc
in a text editor
gnome-text-editor ~/.bashrc
- Add the following line at the end of the txt file:
export PATH="$PATH:/snap/bin"
export PATH="$PATH:/path/to/gem/bin"
Replace /path/to/gem/bin
with your path .
It should look like something like this :
export PATH="$PATH:/home/ali/.gem/bin"
or this :
export PATH="$PATH:/home/your_username/.gem/ruby/3.x.x/bin"
To make sure what is your path , check the gem path using this command in the terminal:
gem env
It will list a long list of things about RubyGems Environment , we need the - EXECUTABLE DIRECTORY:
path line .
Now save your changes and reload your shell config using :
source ~/.bashrc
Now when you download any new gem , it will work automatically , try installing Rspec and test it in both VSCode and Terminal
The reason why I told you to delete the old .gem folder is becasue no one wants to manually edit the shebang line , I don't know what is a shebang but that's what ChatGPT told me .
That's it
See you later
Top comments (1)
Good luck trying to install Ruby-LSP
I can't fix it , it's not working because snap packages 🙄 and I can't find any guide on this subject , not even the docs
I will install Ruby using rbenv now , Good luck guys , I really wanted Ruby snap version this to work .