SublimeLinter-rubocop: /usr/bin/ruby: No such file or directory -- bundle (LoadError)

Having these Sublime Linter settings:

// SublimeLinter Settings - User
{
	"debug": true,
	"linters": {
		"rubocop": {
			"use_bundle_exec": true
		}
	},
	"paths": {
		"osx": [
			"~/.gems/bin"
		]
	}
}

I still get /usr/bin/ruby: No such file or directory -- bundle (LoadError):

SublimeLinter: #7 SublimeLinter.sublime-package:747: 'rubocop' is linting 'main.rb'
SublimeLinter: #7 SublimeLinter.sublime-package:1045: rubocop: main.rb ['/usr/bin/ruby', '-S', 'bundle', 'exec', 'rubocop', '--format', 'emacs', '--force-exclusion', '--stdin', '/path/to/main.rb']
SublimeLinter: #7 SublimeLinter.sublime-package:1048: rubocop: cwd: /path/to
SublimeLinter: #7 SublimeLinter.sublime-package:774: rubocop output:
    /usr/bin/ruby: No such file or directory -- bundle (LoadError)
SublimeLinter: #7 SublimeLinter.sublime-package:815: rubocop: No match for line: '/usr/bin/ruby: No such file or directory -- bundle (LoadError)'

Bundler was installed using the official instructions and is available in the PATH:

> which rubocop
/Users/revolt/.gems/bin/rubocop

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 17 (9 by maintainers)

Most upvoted comments

I’ve run into the same issue. At minimum it should start with /usr/bin/env ruby instead of /usr/bin/ruby, since the various ruby version managers etc. will work correctly if you use the env ruby instead of system.

One user noted (elsewhere) that using Sublime 3.2 the PATH is correct, and the patch https://github.com/SublimeLinter/SublimeLinter/pull/1509 is not necessary anymore. Maybe someone can try that, and report back.

The interesting (and suprising) part for this linter is that it always starts with ruby -S as command. This means SublimeLinter, the framework, never actually tries a simple which rubocop, instead it tries which ruby, and then does a /path/to/ruby -S rubocop.

@joshmfrankel Do you use the master version or my PR #55? I would suspect that it runs ~/.asdf/shims/rubocop -S rubocop if you set executable that way.

I saw that ordering issue before. Don’t know why that happens for some users. (SublimeLinter should not be the cause here. Since we never figured a fix that works for all users, we decided to not ship any fix at all.)

A proposed fix can be found here https://github.com/SublimeLinter/SublimeLinter/pull/1509 This is pretty much a stand-alone fix that can be installed via copy/paste. See the instructions over there.

This might be related. I have a similar issue, seemingly caused by PATH being in the wrong order.

SublimeLinter: #2 util.py:132         PATH:
   /usr/local/Cellar/gettext/0.19.8.1/bin
   /usr/local/opt/mysql@5.7/bin
   ~/local/bin
   /usr/local/sbin
   /usr/local/bin
   /usr/bin
   /bin
   /usr/sbin
   /sbin
   ~/.rbenv/shims # <- correct ruby binary path
   /usr/local/Cellar/gettext/0.19.8.1/bin
   /usr/local/opt/mysql@5.7/bin
SublimeLinter: #2 linter.py:1305      Running ...

 ~/dev/my-project  (working dir)
 $ cat app/file.rb | /usr/bin/ruby -S rubocop --format emacs --force-exclusion --stdin
                     ^^^^^^^^^^^^^ /usr/bin in earlier PATH?

Of course running from a shell resolves to the correct binary.

# using fish shell
$ which ruby
~/.rbenv/shims/ruby

Mitigated with the following configuration, but shouldn’t be needed.

// SublimeLinter Settings - User
{
  "paths": {
    "osx": [
      "~/.rbenv/shims"
    ]
  }
}