castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

Required path could not be resolved #118

Closed taylorthurlow closed 5 years ago

taylorthurlow commented 5 years ago

I'm working in a Rails application and Solargraph is having issues with my require statements. For example, it won't resolve require "aips/image" with the follow directory structure:

lib
└── aips
    ├── acrylic_idea_factory
    │   ├── api.rb
    │   └── xml_file.rb
    ├── dp2_token.rb
    ├── error.rb
    ├── image.rb   
    └── version.rb

My research would suggest that the default path for resolving these paths is the lib folder, assuming there is no gemspec file, which there is not. I have no .solargraph.yml file, but adding one with a require_paths setting has no effect. I'm using bundler as well, with no special bundler configuration.

taylorthurlow commented 5 years ago

I'm also having some issues getting normal gems to work as well. For example, in a test file I have a require "faker" which doesn't resolve.

cmazakas commented 5 years ago

I'm also experiencing this issue.

I have a .solargraph.yml with:

---
include:
- "**/*.rb"
- "./lib/**/*.rb"

and it still doesn't work!

stuartluscombe commented 5 years ago

I have a default .solargraph.yml

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
require_paths: []
max_files: 5000

When I turned diagnostics on to help lint my Rails project I'm getting a warning in every test file of Required path test_helper could not be resolved.

I've tried removing the - test/**/* exclusion as that looked like it would be the problem, but no joy.

castwide commented 5 years ago

Try removing the require_not_found line instead. That's the reporter that tests require paths.

You probably want to keep the - test/**/* exclusion. You'll still be able to get linting and autocomplete on your test files, but the exclusion will keep test classes from being mixed into the rest of your application's API.

I'm looking into making the require_not_found reporter more reliable. At any rate, it's totally optional.

lifeiscontent commented 4 years ago

@castwide any ideas when you'll make the reporter more reliable?

cflannagan commented 4 years ago

Seeing the same issue mentioned here - it appears this issue was closed - what was the resolution?

Edit: Actually, looks like issue is still open elsewhere: https://github.com/castwide/vscode-solargraph/issues/94 (posting here in case someone comes here too looking for a solution)

daniel-gato commented 2 years ago

Same problem here