What I did before this issue was renaming this file. After I rename this file I got:
[Error - 3:54:17 PM] Request textDocument/hover failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog d:/ASPACK/FACILITY/gitsby/gitsby/db/migrate/20190114123505_create_subscription_packages.rb
Code: -32603
Previous name was: 20190114123505_create_subscriptions.rb
New filename: 20190114123505_create_subscription_packages.rb
See here: (watch the cursor position and logs)

Related code:
Sequel.migration do
change do
create_table :subscription_packages do
primary_key :id, type: :Bignum
column :subject, 'character varying(64)', null: false
column :slug, 'character varying(64)', null: false
column :storage_size, 'bigint', null: false
column :price_per_month, 'double precision', null: false
column :price_per_year, 'double precision', null: false
column :discount, 'smallint', default: nil
column :discounted_until, 'timestamp without time zone', default: nil
column :is_active, 'boolean', default: true
column :properties, 'jsonb', default: nil
column :actives_on, 'timestamp without time zone', default: nil
column :expires_on, 'timestamp without time zone', default: nil
column :created_on, 'timestamp without time zone', null: false
column :updated_on, 'timestamp without time zone', default: nil
end
end
end
I'm able to reproduce this one, but not consistently. There seems to be a window between renaming the file and the next ApiMap update during which the file is unrecognized.
Two questions:
Does hover start working again after a few seconds?
No. Still broken.
Does it work again if you close and reopen the file?
Yes. This fixes issue.
Do you get any additional error messages or a stack trace in the developer console?
I didn't see such error other than i reported here.
Currently, my issue goes away but i will keep eye on it. If raises again, I will also check other outputs and devtools.
The master branch includes a change that might fix this issue. I reproduced it with the following steps:
The server would delete the file from both the workspace (if it's included) and the list of open files. The solution is to keep it in the list of open files as long as it's still in an editor window. This behavior is consistent with handling of other unmapped files in editors, e.g., a unit test that's excluded from the workspace. You can still use LSP features while you're editing it, but its definitions get ignored when you switch to a different file.
Fix published in v0.31.1.
Still broken.
[Error - 2:22:27 PM] Request textDocument/hover failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog c:/Users/david/Documents/Coding Projects/fs/InClass/ghostbusters/test/controllers/ghosts_controller_test.rb
Code: -32603
@davidbudnick Are you using 0.31.1?
Does it start working if you close and reopen the file? If so, can you reproduce the steps that made it stop working?
@castwide Looks like disabling and re-enabling the extension fixed the issue.
I will keep you posted if the issue happens again.
Happens to me, for example after checking out a new git branch which changes a bunch of files.
Yes, same here too. Let say you run a rake task that generates a few files. This error occures. Same for if you delete file manually from Explorer while Solargraph is on. (Also same for if you copy a file in VScode then delete the original file)
@MicMicMon @gencer Thanks for the details. I'll reopen this issue and dig further.
The master branch includes a change that forces libraries to update their maps when the language server reports file events. This should fix FileNotFoundErrors that have been happening when external processes create or delete files.
Released in v0.32.2.
No further issues here.
I also confirm that, I no longer see any error since release.
Thank you, Fred!
I was using 0.32.3, I've just upgraded to 0.32.4 and I'm still seeing this problem:
[Error - 12:44:02 PM] Request textDocument/hover failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog /Users/alter/workspace/my_project/lib/tasks/asset_import.rake
Code: -32603
quick review, it looks it's happening only with rake files.
I've been getting it with what seems like just my files in my /test directory?
It has nothing to do with renaming files in my case.
~
[Error - 9:47:45 AM] Request textDocument/hover failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog /Users/taylor/Code/redacted/test/test_helper.rb
Code: -32603
~
This was on v0.32.3, I just updated to v0.32.4 and I'll edit this again if the issue appears again.
EDIT: I can confirm this is happening again on v0.32.4. The error message is slightly different though:
~
[Error - 9:56:37 AM] Request textDocument/completion failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog /Users/taylor/Code/redacted/test/test_helper.rb
Code: -32603
~
Notice the error is textDocument/completion failed and not textDocument/hover failed. This could be irrelevant but I figured I'd note it.
The next version of the gem will log FileNotFoundError for debugging purposes but will not send an error message to output. I'm also working on a way to correct the error in place instead of ignoring it, but this way at least it won't impact usability.
The change is currently in the master branch. I'll try to have it ready for publication tomorrow.
@castwide So you say you'll find the solution to correct the error instead of ignoring it in tomorrow publication.
I'll ignore it either way, just to make sure the error doesn't annoy people by stealing focus in VS Code (or any other client). I hope to find a better long-term solution, but this should be good enough for now. The only side-effect is that hover and autocomplete might be temporarily unavailable while the server catalogs the new file. Cataloging is usually fast enough to be measured in milliseconds, but it looks like there are cases where the client can query the file before it's finished.
Gem v0.32.5 is released. FileNotFoundErrors during completion and hover operations no longer steal focus in the client.
I upgraded to 0.32.5, removed old versions, but still seeing the issue 馃槗
[Error - 11:43:36 AM] Request textDocument/definition failed.
Message: [Solargraph::FileNotFoundError] ApiMap did not catalog /Users/alter/workspace/my_project/test/unit/alert_test.rb
Code: -32603
@alagos Some things that can help us debug:
If you're using a Ruby version manager like rvm or rbenv, it's possible that VS Code is using a different version than what you see on the command line. You can confirm whether the version in VS Code is correct by running Solargraph: Get environment info from the command palette.
When you get this error, is the test/unit/alert_test.rb file open in an editor? Was it recently created, e.g., by a rake task?
What other extensions do you have installed? One of them might be triggering a request that the language server doesn't expect.
I'm using rbenv, but I only have one ruby version. Even if I had another one, I only have installed solargraph on my current ruby version.
The files are only opened in vscode and they aren't new files. The only way I can think to make the files content change out of the editor is when I move to another branch, if that helps.
System
Solargraph
Project
I've just generated a settings sync gist where appears all my extensions installed and also some configs. I've done in vscode.
Gem 0.33.0 includes a fix that should help with this. The problem appears to be related to files that are either excluded from workspace maps, such as unit tests, or files from external libraries. There was a potential window where the language server's library would be out of sync: it would detect that the file was open before it was mapped. 0.33.0 makes sure the library is synchronized.
Gem 0.33.2 introduces one more change that fixes FileNotFoundError in textDocument/references messages, and might finally eliminate the root cause.
The commonality between most/all the errors was a checkout method. Its purpose was to ensure that external files were synced with a library before querying its maps. The error would occur when checkout was called more than once in a single query.
There's already a mechanism in another component that performs much smarter library syncing, so the checkout method was not only unreliable, it was redundant. This version removes it altogether.
My one remaining concern is edge cases in processes that modify the workspace, such as switching repo branches or running rake tasks. Most of those cases should be fine, but I don't know what I don't know. If anyone still runs into this issue, please report it. In the meantime, the workaround is to restart either the language server or the editor that's running it.
The errant workspace synchronization at the core of this issue is resolved, and cases that can be ignored emit a warning instead of stealing focus with an error. If anyone still encounters problems, please open a new issue.
Most helpful comment
Released in v0.32.2.