Why can't I build Ruby code from Sublime Text 3 when I launch it from Ubuntu Dash vs Ubuntu Terminal

Israr Ahmed
  • 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?

Israr Ahmed

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why can't I launch Sublime Text 3 with sudo from my command line?

From Dev

On ubuntu when I run sublime text from the terminal it will open two instances

From Dev

How I can launch Sublime Text 2 from the Mac OS X Terminal?

From Dev

Why can't I launch eclipse from a terminal ? change $PATH environment variable

From Dev

Can I build a Ubuntu ISO from a manifest?

From Java

How can I run a Python script from Ubuntu Dash?

From Dev

How can I run a Python script from Ubuntu Dash?

From Dev

How can I remove the color from build output in Sublime Text 3?

From Dev

Why can't I open `.plist` files in Sublime Text 3

From Dev

Reinstalled Ubuntu, i use separate /home partition, can't launch apps from previous install

From Dev

Why can't I set the default Ruby version in Ubuntu?

From Dev

how to open any file on Sublime text editor 3 from terminal ubuntu 14.04?

From Dev

I can only launch gvim from the terminal and not from the Unity launcher

From Dev

Why can't I gpg-sign the Ubuntu Code of Conduct?

From Dev

How do I remove VS Code & settings from Ubuntu?

From Dev

How can I minify html, css, js/jquery and ruby code inside Sublime Text 3?

From Dev

Can't access to Ubuntu Interface when I open Ubuntu, just Terminal inteface

From Dev

How can I launch pyCharm from terminal to use it with ROS?

From Dev

How can I launch the iOS Simulator from Terminal?

From Dev

How can I launch pyCharm from terminal to use it with ROS?

From Dev

Can't type accented characters in Sublime Text 3 (Ubuntu 14.10)

From Dev

Sublime Text 3 Doesn't Recognize %i in ruby

From Dev

Why can't I rename folders on my Android device from my Ubuntu interface?

From Dev

Why can't I rename folders on my Android device from my Ubuntu interface?

From Dev

Why can't I move files from my Ubuntu desktop to other folders?

From Dev

Why can't I connect to VMWare guest ubuntu via Telnet nor SSH from host?

From Dev

Why can't I just delete or format Windows 10 partition from Ubuntu without using Gparted?

From Dev

Why can't I connect from Ubuntu laptop to a Win7 desktop thru Cisco AnyConnect?

From Dev

Why can I access to my C: or D: drives from Ubuntu?

Related Related

  1. 1

    Why can't I launch Sublime Text 3 with sudo from my command line?

  2. 2

    On ubuntu when I run sublime text from the terminal it will open two instances

  3. 3

    How I can launch Sublime Text 2 from the Mac OS X Terminal?

  4. 4

    Why can't I launch eclipse from a terminal ? change $PATH environment variable

  5. 5

    Can I build a Ubuntu ISO from a manifest?

  6. 6

    How can I run a Python script from Ubuntu Dash?

  7. 7

    How can I run a Python script from Ubuntu Dash?

  8. 8

    How can I remove the color from build output in Sublime Text 3?

  9. 9

    Why can't I open `.plist` files in Sublime Text 3

  10. 10

    Reinstalled Ubuntu, i use separate /home partition, can't launch apps from previous install

  11. 11

    Why can't I set the default Ruby version in Ubuntu?

  12. 12

    how to open any file on Sublime text editor 3 from terminal ubuntu 14.04?

  13. 13

    I can only launch gvim from the terminal and not from the Unity launcher

  14. 14

    Why can't I gpg-sign the Ubuntu Code of Conduct?

  15. 15

    How do I remove VS Code & settings from Ubuntu?

  16. 16

    How can I minify html, css, js/jquery and ruby code inside Sublime Text 3?

  17. 17

    Can't access to Ubuntu Interface when I open Ubuntu, just Terminal inteface

  18. 18

    How can I launch pyCharm from terminal to use it with ROS?

  19. 19

    How can I launch the iOS Simulator from Terminal?

  20. 20

    How can I launch pyCharm from terminal to use it with ROS?

  21. 21

    Can't type accented characters in Sublime Text 3 (Ubuntu 14.10)

  22. 22

    Sublime Text 3 Doesn't Recognize %i in ruby

  23. 23

    Why can't I rename folders on my Android device from my Ubuntu interface?

  24. 24

    Why can't I rename folders on my Android device from my Ubuntu interface?

  25. 25

    Why can't I move files from my Ubuntu desktop to other folders?

  26. 26

    Why can't I connect to VMWare guest ubuntu via Telnet nor SSH from host?

  27. 27

    Why can't I just delete or format Windows 10 partition from Ubuntu without using Gparted?

  28. 28

    Why can't I connect from Ubuntu laptop to a Win7 desktop thru Cisco AnyConnect?

  29. 29

    Why can I access to my C: or D: drives from Ubuntu?

HotTag

Archive