Closed chiperific closed 3 years ago
Hm, nice error output when we actually give it one(!) file path. Within SublimeLinter you can mess around with the executable
setting. For the original post, or automatically by default, it is set to
["/Users/ckragt/.rvm/bin/rvm-auto-ruby", "-S", "rubocop"]
Variants are ["bundle", "exec", "rubocop"]
, or just ["abs/path/to/rubocop"]
.
Since the args include --stdin
when trying on the Terminal you have to pipe something in. Either from the left cat x.rb |
or from the right <
. Please try the commands from the Terminal because if it doesn't work there, it never works within Sublime. (And it's faster to debug on the CLI anyway.)
Oh, you heavy edited the OP. Seems like you already tried the Terminal. Then I would open a question on the rubocop tracker. Esp. "relative to the root of the project" seems vague because we actually pass an absolute path. I think they mean the file your pointing at must be below the working dir. Actually "requires exactly one path" is also vague because could it be a dirname
? I don't think so, they mean a full path to a file.
So, I was posting the issue to RuboCop's repo and I had a total facepalm moment. Somehow I managed to turn my .rubocop.yml
file into just .rubocop
For some reason, not having the .yml
extension on the file caused this screwy error.
But that's worth an issue. I treat misleading error messages as a bug. And ambiguous wording is also an issue... No?
I'll grant it's not the best error message, but it seems to be a pretty edge case. I wouldn't expect them to write a custom error message for this scenario.
The first line of my .rubocop.yml
file is:
Layout/LineLength:
I'm a bit of a novice, so this is an uneducated guess, but it seems that not having the .yml
extension led to RuboCop treating that line as an addition to the path:
Terminal output running RuboCop (without SublimeLinter) when the file is named .rubocop
:
$ rubocop
> Inspecting 28 files
> .
>
> 0 files inspected, no offenses detected
> Error: No such file or directory: /Users/ckragt/ruby/ceremonial/Layout/LineLength:
I guess I would have expected the error message to read "Error: No such file or directory", and if you agree, I'll post it as a bug. But, even this message wouldn't have necessarily gotten me to recognize my mistake.
Hm, didn't know this but .rubocop
is a special file. https://github.com/rubocop-hq/rubocop/blob/19781234c3d8ed97d8c0ecbafbb5653a4671b9a4/lib/rubocop/options.rb#L47-L53
Default command-line options are loaded from .rubocop and RUBOCOP_OPTS and are combined with command-line options that are explicitly passed to rubocop. Thus, the options have the following order of precedence (from highest to lowest):
1. Explicit command-line options
2. Options from RUBOCOP_OPTS environment variable
3. Options from .rubocop file.
from https://docs.rubocop.org/rubocop/1.0/usage/basic_usage.html#command-line-flags
So basically it's a feature not a bug. 🤷
You learn something new everyday.
My rubocop doesn't seem to be working. I've tried uninstalling/reinstalling the gem and the linter with no luck.
I've been seeing this warning message in the console:
I'm assuming it's related to this command:
bundle exec rubocop --format emacs --force-exclusion --stdin /Users/ckragt/ruby/ceremonial/app/models/element.rb
But running that in Terminal (zsh) gives me the same result, and messing with the options doesn't seem to change anything.
My settings look like this:
Running
which rubocop
outputs this:/Users/ckragt/.rvm/gems/ruby-2.7.0/bin/rubocop
My gemfile has rubocop:
Using rubocop 1.0.0
Could this be causing my lack of linting issue? I'm not sure what to do about this warning, or that it's the cause of my issue, but I'm out of other ideas.