castwide / solargraph

A Ruby language server.
https://solargraph.org
MIT License
1.88k stars 155 forks source link

Issue loading required files in bundler, under LSP in Emacs #417

Open asg0451 opened 3 years ago

asg0451 commented 3 years ago

I've written out my full issue in the lsp-mode repo: https://github.com/emacs-lsp/lsp-mode/issues/2646 But I'll summarize here as well. Using solargraph as an LSP backend in emacs, I can't get it to grok files that I require that are outside of the workspace tree. Files in gem dependencies that are declared in my Gemfile.

I'm allegedly running solargraph under bundler. I know very little about that setup but I can perform any debugging step you think might be helpful.

mcmire commented 3 years ago

I'm having the same issue. I've got a project with a Gemfile with a gem specified there, and I'm trying to require that gem in a file, but the require_not_found reporter is kicking in. I'm using coc-solargraph in Vim, but it (allegedly) has a way to specify solargraph.useBundler as mentioned here.

Are there any known issues with Bundler?

castwide commented 2 years ago

There are two possible causes here. Solargraph loads the yardocs for external gems instead of trying to parse every dependency's code. You can run yard gems to ensure that all your gems have yardocs. More information: https://solargraph.org/guides/yard

Solargraph also can't detect yardocs in gems loaded from paths. This is the issue with the example project from emacs-lsp/lsp-mode#2646. If you load solartest/one as a workspace, it doesn't have access to solartest/thelib. If you load solartest as a workspace, however, both directories get mapped. Unfortunately, there isn't currently a good solution for loading a gem from a path in a different directory.

hugrs commented 2 years ago

If this helps advance this issue, I was having the same problem as described by the author and running bundle exec yard gems solved it for me. My setup is Doom Emacs with lsp-mode and solargraph.

I now realize that this is documented in https://github.com/castwide/solargraph#solargraph-and-bundler. Sadly search engines don't redirect there when searching for the error message "Required path could not be resolved".

asg0451 commented 2 years ago

@castwide

Solargraph also can't detect yardocs in gems loaded from paths Ok, thanks. I'm curious - why is this the case? is there any room for potential improvements here? if you could point me in a direction i might be able to take a crack at it.