2
  • ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
  • which ruby: /home/iuser/.rbenv/shims/ruby
  • rails -v: Rails 4.2.3
  • subl -v: Sublime Text Build 3126
  • Ubuntu: Ubuntu 16.04.1 LTS

It doesn't matter from which directory I launch the Sublime Text 3 from, as long as I launch it using subl from terminal, I am able to build any Ruby code, using the Ctrl + B even when the settings are the Tools > Build System > Automatic.

However, when I launch the same Sublime Text 3 from Ubuntu Dash, I am not able to build Ruby Code, and I get the following error:

/bin/bash: ruby: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: ruby "/home/iuser/Desktop/1.rb"]
[dir: /home/iuser/Desktop]
[path:/home/iuser/bin:/home/iuser/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

Even though $PATH returns:

bash: /home/iuser/.rbenv/plugins/ruby-build/bin:/home/iuser/.rbenv/shims:/home/iuser/.rbenv/bin:/home/iuser/bin:/home/iuser/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:

I was able to overcome this by making a custom build system which pointed to the rbenv and then changing the Sublime Text 3 Tools > Build System > MyCustomBuild (http://snakelab.cc/2014/12/10/sublime_3_and_rbenv.html)

My question is:

  1. Why do I need to make a custom build system, and why its not picking up the rbenv just like the Sublime Text 3 which is started from terminal?

  2. How can I make changes so that no matter where I start the Sublime Text 3 from, even if the build system is set to Automatic, it always builds the ruby code?

1
  • 1
    You probably have settings in .bashrc which add ruby to your PATH. If you add stuff to your PATH, use .profile for it.
    – muru
    Dec 22, 2016 at 2:50

1 Answer 1

2

Thanks to muru, I was able to fix this issue

Initially I did the configuration in the following manner:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

The correct method lies in echo-ing to ~/.profile instead of ~/.bashrc:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(rbenv init -)"' >> ~/.profile
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.profile
source ~/.profile
1
  • Just a small note, in order for this to work successfully, I had to restart. Logging out may have also worked as essentially your desktop session needs to resource ~/.profile
    – Mr. Tim
    Nov 28, 2018 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .