ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
859 stars 277 forks source link

Find all references not working in M1 #1707

Closed leolorenzoluis closed 2 years ago

leolorenzoluis commented 2 years ago

Describe the bug

Not sure if its M1 related but this is the only thing I can think of that is different between my laptops. Find all references works fine in an intel laptop, but with M1 find references is broken. It only finds references within its function scope. All my dotnet, ionide, etc versions are all the same.

It's able to find the declaration, but when it goes to the declaration and I try to find references, then it doesn't find it.

Steps to reproduce

  1. Open a FS Code with simple references2.
  2. Find all references
  3. Notice the difference of find reference results between M1 and Intel based

    Link to sample reproduction

    https://github.com/Dzoukr/Yobo

Expected behaviour

Same results as Intel based

Screenshots

This is the output from F#

[Error - 12:59:33 AM] Request textDocument/references failed.
  Message: Request cancelled (exn was System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libe_sqlite3, 0x0001): tried: 'libe_sqlite3' (no such file), '/usr/local/lib/libe_sqlite3' (no such file), '/usr/lib/libe_sqlite3' (no such file), '/Users/l337/Projects/LearningSAFE/libe_sqlite3' (no such file)
   at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()
   at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()
   at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
   at SQLitePCL.Batteries_V2.Init()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   at Microsoft.Data.Sqlite.SqliteConnection..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
   at SymbolCache.PersistentCacheImpl.initializeCache(String dir) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete.Core/SymbolCache.fs:line 108
   at SymbolCache.PersistentCacheImpl.lazyConn@136.Invoke() in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete.Core/SymbolCache.fs:line 136
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at SymbolCache.getSymbols@170-2.Invoke(Unit unitVar) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete.Core/SymbolCache.fs:line 172
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 447
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104)
  Code: -32603 

Machine info

Additional context

Add any other context about the problem here.

baronfel commented 2 years ago

Thanks for reporting this issue (and the associated one in FSAC). We may need to investigate an alternative implementation for our symbol cache, or look at removing the concept now that the compiler services have some additional APIs for us to use for the areas we introduced the symbol cache for.

baronfel commented 2 years ago

Also as a workaround, you can set "FSharp.enableBackgroundServices": false in your workspace settings to disable the background services, which is our only use of the sqlite library that's erroring.

leolorenzoluis commented 2 years ago

@baronfel Disabling the background services just hides the error. It still doesn't work properly with find all references, so I'm guessing this is a different bug somewhere not related to symbol cache?

Krzysztof-Cieslak commented 2 years ago

Finding references should be fixed in 7.0.0