Error Building Ruby in Sublime Text Editor

2019-02-14 19:42发布

问题:

puts "Hello World!"

When I click CTRL+B (Tools->Build) I get the following error in the console

[Errno 2] No such file or directory [cmd: [u'~/.rvm/bin/rvm-auto-ruby', u'/home/ubuntu/rails_projects/Ruby/c2f.rb']] [dir: /home/ubuntu/rails_projects/Ruby] [path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games] [Finished]

Below is the Ruby.sublime-build

{
    "cmd": ["~/.rvm/bin/rvm-auto-ruby", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.ruby"
}

I'm running this in Ubuntu 12.04, Sublime Text 2.0.1

~/.rvm/bin/rvm-auto-ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

What am I missing? I also have Ruby Test set up and that's working.

回答1:

The problem seems to be the ~ in your Ruby command path. It may not be very general, but try to change

"cmd": ["~/.rvm/bin/rvm-auto-ruby", "$file"]

with

"cmd": ["/home/your_username/.rvm/bin/rvm-auto-ruby", "$file"]