castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
424 stars 25 forks source link

Solargraph::FileNotFoundError #47

Closed bartimez closed 6 years ago

bartimez commented 6 years ago

I was having this issue and after uninstalling and reinstalling the Solargraph gem, I am now getting an error in the integrated terminal every time I open a file in my workspace:

[Error - 09:30:33] Request textDocument/documentSymbol failed.
  Message: [Solargraph::FileNotFoundError] Source not found for /path/to/whatever/file.rb
  Code: -32603 
castwide commented 6 years ago

A similar issue was reported in #46.

Does it happen immediately upon opening the file, or are you trying to run Go to symbol in file? (That's typically when the textDocument/documentSymbol request happens.)

What OS are you using?

Did you install gem v0.20.0?

Are you using a multi-root workspace?

Do you have a .solargraph.yml file?

Do you get any other error messages in the developer console (Help -> Toggle Developer Tools)?

bartimez commented 6 years ago

It happens immediately upon opening the file.

I'm using OS 10.12.6.

solargraph -v returns 0.20.0.

I am not using a multi-root workspace, and I do not have a .solargraph.yml file.

Here is the output in the developer console:

  ERR write EPIPE: Error: write EPIPE
    at exports._errnoException (util.js:1050:11)
    at WriteWrap.afterWrite [as oncomplete] (net.js:813:14)
console.ts:136 [Extension Host] The Solargraph gem is installed and working.
console.ts:136 [Extension Host] Checking gem version
console.ts:136 [Extension Host] Solargraph is listening PORT=58539 PID=5526

console.ts:136 [Extension Host] warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.7-compliant syntax, but you are running 2.3.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

console.ts:136 [Extension Host] Solargraph gem version is current
console.ts:136 [Extension Host] WARN: Unresolved specs during Gem::Specification.reset:

console.ts:136 [Extension Host]       coderay (~> 1.1)
      rake (>= 0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 1.0.1, ~> 1.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.

console.ts:136 [Extension Host] Source not found for /path/to/the/file.rb
console.ts:136 [Extension Host] 
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0.20.0/lib/solargraph/library.rb:264:in `read'
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0.20.0/lib/solargraph/library.rb:195:in `file_symbols'
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0.20.0/lib/solargraph/language_server/host.rb:320:in `file_symbols'
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0…/lib/solargraph/language_server/message/text_document/document_symbol.rb:5:in `process'
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0.20.0/lib/solargraph/language_server/host.rb:62:in `start'
/Users/brittany/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/solargraph-0.20.0/lib/solargraph/language_server/transport/socket.rb:19:in `block in process'
castwide commented 6 years ago

Thanks. This one looks new to me. I'll try to reproduce it on MacOS.

How are you opening the file? (e.g., clicking on it in the explorer or using a keyboard shortcut)

Do you have any other extensions installed, or any user/workspace settings changed in VSCode? (I'm not even sure where to start looking for a root cause, so I'm fishing a bit.)

bartimez commented 6 years ago

No problem - thank you for looking into it.

I'm opening the file by using cmd-P, typing part of the filename, and then hitting return.

I have the following extensions: Auto Close Tag Charcoal Oceanic Next Cucumber (Gherkin) Full Support Debugger for Chrome elm GitLens Material Icon Theme mssql One Monokai Theme Ruby Ruby Solargraph, of course Sass VSCode Great Icons

Here are my custom User Settings:

{
    "editor.minimap.enabled": false,
    "editor.tabSize": 2,
    "editor.wordWrap": "on",
    "window.restoreWindows": "all",
    "editor.fontSize": 16,

    // Auto Close Tag
    "auto-close-tag.SublimeText3Mode": true,
    "auto-close-tag.activationOnLanguage": [
        "erb",
        "ruby"
    ],

    //VSCODE-RUBY INTELLISENSE - turned off
    "ruby.intellisense": "none",

    // VSCODE-RUBY LINTERS (see github.com/rubyide/vscode-ruby)
    "ruby.lint": {
        "reek": false,
        "rubocop": {
            // "only": [Add cops here]
            // "lint": true,
            "rails": true
        },
        "ruby": true, //Runs ruby -wc
        "fasterer": true,
        "debride": false,
        "ruby-lint": false
    },

    "terminal.integrated.fontSize": 14,
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Charcoal Oceanic Next",
    "workbench.iconTheme": "material-icon-theme",
    "workbench.editor.enablePreview": false,
    "workbench.activityBar.visible": false,
    "workbench.panel.location": "right",
    "gitlens.advanced.messages": {
        "suppressCommitHasNoPreviousCommitWarning": false,
        "suppressCommitNotFoundWarning": false,
        "suppressFileNotUnderSourceControlWarning": false,
        "suppressGitVersionWarning": false,
        "suppressLineUncommittedWarning": false,
        "suppressNoRepositoryWarning": false,
        "suppressResultsExplorerNotice": false,
        "suppressShowKeyBindingsNotice": true,
        "suppressUpdateNotice": false,
        "suppressWelcomeNotice": true
    },

    //elm language support
    "elm.formatOnSave": true,
    "gitlens.keymap": "chorded"
}
BobbyMcWho commented 6 years ago

@bartimez I was also seeing this problem until I created a .solargraph.yml at the root of the project with contents:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
reporters: []
domains: []
required: []
plugins: []
bartimez commented 6 years ago

@BobbyMcWho, I gave that a try just now, but unfortunately, it is still happening for me. :(

castwide commented 6 years ago

I'm afraid I haven't been able to reproduce this error yet. @bartimez, can you confirm for me if a bare minimum project works for you?

  1. Create a folder containing one empty file with an .rb extension.
  2. Open the folder in VS Code.
  3. Open the file and start editing to see if you get completion suggestions.

Also, can you tell me where the file in the error message is located? I'm mostly curious whether a) it's outside of the workspace directory, or b) it's in a file that's excluded from mapping.

Someone mentioned in another issue that the LSP specification does not require the didOpen method to be called on a file before operating on it, which might be related.

bartimez commented 6 years ago

@castwide, thanks for your help on this.

A bare minimum project does indeed work for me:

screen shot 2018-04-30 at 11 01 16 am

My top-level workspace directory is /Users/brittany/repos/repo_name. All of the files that have produced this error are located within subdirectories of /Users/brittany/repos/repo_name. For example, I've just opened the file at /Users/brittany/repos/repo_name/app/controllers/controller_name.rb and the error appeared.

castwide commented 6 years ago

Thanks, @bartimez. The best I can guess, it looks like VSCode is trying to collect the document's symbols before it notifies the server that it opened the file. I haven't seen that happen before, but it's a valid operation according to the LSP specs, so I'm going to change the way the server handles it.

castwide commented 6 years ago

The gem's master branch maps files that haven't been flagged open by the client. The FileNotFoundError should only occur if the file doesn't exist either on disk or in memory (e.g., an unsaved file in an editor).

Gem version 0.21.0 should be available by May 7.

castwide commented 6 years ago

Gem version 0.21.0 is published.

castwide commented 6 years ago

@bartimez Can you confirm whether the issue is resolved with the latest gem? It fixes the problem with erroneous FileNotFoundErrors in general, but since I wasn't sure of your root cause, I can't confirm whether it works in your particular case.

bartimez commented 6 years ago

@castwide - Unfortunately I ended up uninstalling the gem completely because I began experiencing this issue. I'll try reinstalling sometime next week and will update this issue to let you know whether the FileNotFound errors have resolved.

Thanks again for your help with this.

castwide commented 6 years ago

@bartimez Thanks for the followup. If you still run into problems, please let me know.

castwide commented 6 years ago

I'm closing this issue since the original problem with FileNotFoundError should be resolved. If anyone still has problems with either that or CPU usage, please open a new issue.