Setup SublimeLinter with RVM and ZSH under Linux Mint 19.3 Cinnamon

Setup SublimeLinter with RVM and ZSH under Linux Mint 19.3 Cinnamon

In my previous posts I took you onto a journey from my old macOS environment to my new home - Linux Mint 19.3 Cinnamon.

As with every journey, you have quests to solve. This time I wanted to get Sublime Text with Sublime Linter running again on my new home. The challenge here was to get it work with ZSH as my default shell and RVM.

You will see that in the end, the setup is quite easy. It took me some hours to figure that out as I wanted to solve it differently before.

Installing and configuring ZSH

By default Mint comes with the Bash preinstalled and configured. I already switched to ZSH on macOS with Catalina and also used oh-my-zsh together with it. It's really awesome as it makes working with the shell faster and easier - even for me as a professional day-by-day shell user.

To install ZSH on Mint, simply install the package first and then make it your default shell.

sudo apt-get -y install zsh git-core
chsh -s /bin/zsh

After that, logout of your current desktop session or reboot the machine once.

After that, if you want to have all the benefits of oh-my-zsh, just read the Install section in their Readme.

Install RVM and a ruby

Next step is to install RVM and a ruby to work with. For that simply execute the following commands in your shiny new ZSH.

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL | bash -s stable

This will install RVM. To load it, restart the current terminal session or invoke source $HOME/.rvm/scripts/rvm once.

To have the new environment ready when you need it including your rubies, add the following line to ~/.zshenv. This will autoload the RVM environment for each ZSH session.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Relogin again, then continue.

Install a Ruby

Now let us install a ruby version and directly make it the default ruby. This means it is automatically used when you just type ruby in your command line.

rvm install --default ruby-2.6.3

Done. Now you should be already able to run ruby or gem in your terminal. Check the running ruby version as follows.

ruby -v
-> ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

Install SublimeLinter and configure it

For our example I will use the puppet-lint gem, as I need it every day. Install this first with:

gem install puppet-lint

As of today it will install v2.4.2.

Next open Sublime Text. Press Shift+Ctrl+P to open the command prompt and install Package Control first. Then press the same commands again to run Package Control: Install package. This will download the repositories and show you all possible installation candidates.
Install the SublimeLinter package first, then repeat with the SublimeLinter-contrib-puppetlint package.

This will make everything available.
When you now open the SublimeText Console and then a new file it will tell you that it cannot find ruby or the puppet-lint binary. We expected this.

Configure the SublimeLinter path variables

Open a terminal and run the following two commands, to check where your rvm-auto-ruby binary and gems reside.

which rvm-auto-ruby
-> /home/username/.rvm/bin/rvm-auto-ruby
which puppet-lint
-> /home/username/.rvm/gems/ruby-2.6.3/bin/puppet-lint

As we don't want to always change the path of the second, when we update ruby, RVM created a default path for us which always points to our default gemset. Rvm-auto-ruby always automatically points to the current default ruby.

The paths are as follows.

-> Ruby (rvm-auto-ruby)
-> Gems

In Sublime Text click on Preferences -> Package Settings -> SublimeLinter -> Settings.
A new window opens with the default/available settings on the left side and the user-defined ones on the right.

On the right side add the following new path variables. Make sure to replace username with your actual username.

"paths": {
		"linux": ["/home/username/.rvm/bin/", "/home/username/.rvm/gems/default/bin/"],

Now restart SublimeText once. Then open it again.

Create a file with the following content. SublimeLinter with puppet-lint should show you a warning and an error upon saving this file (which fires a puppet-lint run).

class test {
  $variable = "Should be single quoted."

If you see the two, congratulations.


It looks like an easy setup but it really took me a while to figure this out. I always tried to make the RVM loading work within Sublime to have the same environments $PATH variable available as in my ZSH environment. As you can see this is actually not necessary and with this solution, each ruby based gem will work in Sublime just fine.