vscode-solargraph
vscode-solargraph copied to clipboard
require_not_found cannot find spec_helper
I get an error whenever I open an rspec file, "Required path spec_helper could not be resolved." I'm wondering if it's because the spec/
directory is not on the library search path? One workaround would be to add it, but I can't find a Solargraph option for that.
NB: I tried to exclude my RSpec files from checks, but that has no effect for me. Reported here: #93
Would an option similar to Ruby's -I
CLI option be enough to fix this?
Rubocop has nice solutions for this. E.g., one can exclude certain files from a certain check. I use this to tailor the checks for specs, eliminating the false positives:
Metrics/BlockLength:
Exclude:
- spec/**/*
https://medium.freecodecamp.org/rubocop-enable-disable-and-configure-linter-checks-for-your-ruby-code-475fbf11046a
That's one possibility. In .solargraph.yml, I imagine it would look something like this:
reporters:
- require_not_found:
exclude:
- spec/**/*
Another option is allowing .solargraph.yml files in subdirectories. Right now, Solargraph only checks the project root, but the ability to apply a different configuration to the spec
folder could be helpful. (I'm already looking at this feature for other reasons.)
Hey @castwide did you ever follow-up on this?
This issue still persists. Anyone willing to look up to this issue?
I'm glad I finally found this issue. I'm going to guess / hope that this is what I'm seeing.
In my rspec files, there is a require 'rails_helper'
line which someone is flagging with a Warning of "Required path rails_helper could not be resolved.". I say someone because I have quite a complicated set up with Emacs, lsm-mode, Solargraph along with docker containers. I could't tell if it was Rubocop, Solargraph, Flymake, etc.
Rubocop, when run alone on the command line doesn't complain. And I'm new to lsm-mode, Solargraph, Rubocop, etc so it has taken me a while to finally find this.
Being new, I have more questions than answers:
- Who is actually reporting the error? I guess it is Solargraph or is it Rubocop when invoked via Solargraph?
- Can I tag the line perhaps with a magic comment to tell whoever to ignore this error? I think I'd rather have that than a global ignore.
It seems like the equivalent of load_path
is what is needed.
@castwide It appears that you or someone implemented the pattern in this post at some point and didn't close / reference this issue. We tried it and it worked, but I couldn't find any indication in docs that this was the case. If at all possible, this would also be great to see on the configuration docs to help people looking to fix the warnings in specs.
@TikiTDO Are you sure that it worked? I'm using version 0.50.0 and if I add that snippet to my .solargraph.yml file it causes solargraph to crash with an error: undefined method split
for require_not_found.
All that snippet does is prevent it from running a check on the spec files. There's really not much to not work.
Try to find what it's splitting, maybe you left something blank.
On Mon, Jan 15, 2024, 2:40 AM Jeff Bigler @.***> wrote:
@TikiTDO https://github.com/TikiTDO Are you sure that it worked? I'm using version 0.50.0 and if I add that snippet to my .solargraph.yml file it causes solargraph to crash with an error: undefined method split for require_not_found.
— Reply to this email directly, view it on GitHub https://github.com/castwide/vscode-solargraph/issues/94#issuecomment-1891480287, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPUKE62QBS6TNPDF5MGK3YOTMNBAVCNFSM4GMREFWKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBZGE2DQMBSHA3Q . You are receiving this because you were mentioned.Message ID: @.***>