Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Nuget references unreliable in .fsx files when starting VS Code #2005

Closed
beyon opened this issue Apr 25, 2024 · 3 comments · Fixed by ionide/FsAutoComplete#1275
Closed
Labels

Comments

@beyon
Copy link

beyon commented Apr 25, 2024

Describe the bug

When opening workspaces with .fsx files open in VS Code I often get

The namespace or module 'packagename' is not defined

for packages referenced with

#r "nuget: packagename"

Running the Developer: Reload Window command from the Command Palette can make the error go away after one or more attempts.

I just noticed that having multiple (as little as two) different .fsx files open in split editor (both files visible at the same time) makes it much more frequent, to the point of one file/editor causing an error almost every time.
Not entirely sure I was seeing the same issue without split editor, I thought I was but it seems hard to reproduce so could be I'm just imagining.

Steps to reproduce

Create two .fsx files both referencing some nuget packages.
View: Split Editor command from Command Palette or keyboard shortcut
Arrange so both files are open/visible at the same time in the different halves of the editor.
Developer: Reload Window command from the Command Palette (or close and restart VS Code opening the same workspace)
On my machine one of the files will fail to resolve the dependency (almost?) every time.

bild

Expected behavior

Dependencies resolving for script files upon starting VS Code (or reloading window) even if multiple editors and files are open.

Workaround

Make sure only one .fsx file is open and visible in workspace. Reload window until it works.

Machine infos

  • Operating system: Windows_NT
  • Arch: x64
  • VSCode: 1.88.1
  • UI Kind: Desktop
  • Ionide: 7.18.2
  • Runtime: netcore
  • Dotnet version: 8.0.100
@TheAngryByrd
Copy link
Member

TheAngryByrd commented Apr 25, 2024

Thank you for a good repro! I've had this happen so often but difficult to see it repro it was difficult to find time to try to fix it.

@TheAngryByrd
Copy link
Member

I added ionide/FsAutoComplete#1248 a bit ago to help diagnose this and I end up with:

C:\Program Files\dotnet\sdk\8.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\Users\jimmy.packagemanagement\nuget\Projects\251972--31cbe924-5124-4242-968f-17358f43591c\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\Users\jimmy.packagemanagement\nuget\Projects\251972--31cbe924-5124-4242-968f-17358f43591c\Project.fsproj]F#

I'm guessing there's some restore not happening on F# Compiler Service side, probably can't handle parallel requests.

@beyon
Copy link
Author

beyon commented Apr 25, 2024

@TheAngryByrd I'm glad that my repro was helpful and great work in solving the issue so quickly!

TheAngryByrd added a commit to ionide/FsAutoComplete that referenced this issue Apr 30, 2024
* Shift multiline paren contents less aggressively (#1242)

* Shift multiline paren contents less aggressively

* Make it actually work

* Disambiguate AsSpan overload

* Add some code fixes for type mismatch. (#1250)

* Migrate FAKE to Fun.Build (#1256)

* Migrate FAKE to Fun.Build

* Add default Build pipeline.

* Purge it with fire (#1255)

* Bump analyzers and Fantomas (#1257)

* Add empty, disabled tests for go-to-def on C# symbol scenario

* fix unicode characters in F# compiler diagnostic messages (#1265)

* fix unicode chars in F# compiler diagnostic messages

* fix typo in ShadowedTimeouts focused tests

* fixup! fix unicode chars in F# compiler diagnostic messages

* remove focused tests...

* remove debug prints

Co-authored-by: Jimmy Byrd <[email protected]>

---------

Co-authored-by: Jimmy Byrd <[email protected]>

* - remove an ignored call to protocolRangeToRange (#1266)

- remove an ignored instance of StreamJsonRpcTracingStrategy

* Place XML doc lines before any attribute lists (#1267)

* Don't generate params for explicit getters/setters as they are flagged invalid by the compiler (#1268)

* bump ProjInfo to the next version to get support for loading broken projects and loading traversal projects (#1270)

* only allow one GetProjectOptionsFromScript at a time (#1275)

ionide/ionide-vscode-fsharp#2005

* changelog for v0.72.0

* changelog for v0.72.1

* Use actualRootPath instead of p.RootPath when peeking workspaces. (#1278)

This fix the issue where rootUri was ignored when using AutomaticWorkspaceInit.

* changelog for v0.72.2

---------

Co-authored-by: Brian Rourke Boll <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Krzysztof Cieślak <[email protected]>
Co-authored-by: MrLuje <[email protected]>
Co-authored-by: dawe <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: oupson <[email protected]>
TheAngryByrd added a commit to ionide/FsAutoComplete that referenced this issue May 6, 2024
* Shift multiline paren contents less aggressively (#1242)

* Shift multiline paren contents less aggressively

* Make it actually work

* Disambiguate AsSpan overload

* Add some code fixes for type mismatch. (#1250)

* Migrate FAKE to Fun.Build (#1256)

* Migrate FAKE to Fun.Build

* Add default Build pipeline.

* Purge it with fire (#1255)

* Bump analyzers and Fantomas (#1257)

* Add empty, disabled tests for go-to-def on C# symbol scenario

* fix unicode characters in F# compiler diagnostic messages (#1265)

* fix unicode chars in F# compiler diagnostic messages

* fix typo in ShadowedTimeouts focused tests

* fixup! fix unicode chars in F# compiler diagnostic messages

* remove focused tests...

* remove debug prints

Co-authored-by: Jimmy Byrd <[email protected]>

---------

Co-authored-by: Jimmy Byrd <[email protected]>

* - remove an ignored call to protocolRangeToRange (#1266)

- remove an ignored instance of StreamJsonRpcTracingStrategy

* Place XML doc lines before any attribute lists (#1267)

* Don't generate params for explicit getters/setters as they are flagged invalid by the compiler (#1268)

* bump ProjInfo to the next version to get support for loading broken projects and loading traversal projects (#1270)

* only allow one GetProjectOptionsFromScript at a time (#1275)

ionide/ionide-vscode-fsharp#2005

* changelog for v0.72.0

* changelog for v0.72.1

* Use actualRootPath instead of p.RootPath when peeking workspaces. (#1278)

This fix the issue where rootUri was ignored when using AutomaticWorkspaceInit.

* changelog for v0.72.2

* Add support for Cancel a Work Done Progress  (#1274)

* Add support for Cancel WorkDoneProgress

* Fix up saving cancellation

* package the tool for .NET 8 as well (#1281)

* update changelogs

* Adds basic OTel Metric support to fsautocomplete (#1283)

---------

Co-authored-by: Brian Rourke Boll <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Krzysztof Cieślak <[email protected]>
Co-authored-by: MrLuje <[email protected]>
Co-authored-by: dawe <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: oupson <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
TheAngryByrd added a commit to ionide/FsAutoComplete that referenced this issue May 9, 2024
* Shift multiline paren contents less aggressively (#1242)

* Shift multiline paren contents less aggressively

* Make it actually work

* Disambiguate AsSpan overload

* Add some code fixes for type mismatch. (#1250)

* Migrate FAKE to Fun.Build (#1256)

* Migrate FAKE to Fun.Build

* Add default Build pipeline.

* Purge it with fire (#1255)

* Bump analyzers and Fantomas (#1257)

* Add empty, disabled tests for go-to-def on C# symbol scenario

* fix unicode characters in F# compiler diagnostic messages (#1265)

* fix unicode chars in F# compiler diagnostic messages

* fix typo in ShadowedTimeouts focused tests

* fixup! fix unicode chars in F# compiler diagnostic messages

* remove focused tests...

* remove debug prints

Co-authored-by: Jimmy Byrd <[email protected]>

---------

Co-authored-by: Jimmy Byrd <[email protected]>

* - remove an ignored call to protocolRangeToRange (#1266)

- remove an ignored instance of StreamJsonRpcTracingStrategy

* Place XML doc lines before any attribute lists (#1267)

* Don't generate params for explicit getters/setters as they are flagged invalid by the compiler (#1268)

* bump ProjInfo to the next version to get support for loading broken projects and loading traversal projects (#1270)

* only allow one GetProjectOptionsFromScript at a time (#1275)

ionide/ionide-vscode-fsharp#2005

* changelog for v0.72.0

* changelog for v0.72.1

* Use actualRootPath instead of p.RootPath when peeking workspaces. (#1278)

This fix the issue where rootUri was ignored when using AutomaticWorkspaceInit.

* changelog for v0.72.2

* Add support for Cancel a Work Done Progress  (#1274)

* Add support for Cancel WorkDoneProgress

* Fix up saving cancellation

* package the tool for .NET 8 as well (#1281)

* update changelogs

* Adds basic OTel Metric support to fsautocomplete (#1283)

* Some parens fixes (#1286)

See dotnet/fsharp#16901

* Keep parens around outlaw `match` exprs (where the first `|` is
  leftward of the start of the `match` keyword).

* Ignore single-line comments when determining offsides lines.

* Don't add a space when removing parens when doing so would result in
  reparsing an infix op as a prefix op.

* Run LSP tests sequenced (#1287)

I'm tired of all the weird failures because of parallelism

---------

Co-authored-by: Brian Rourke Boll <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Krzysztof Cieślak <[email protected]>
Co-authored-by: MrLuje <[email protected]>
Co-authored-by: dawe <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: oupson <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants