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

Crash on initialisation when included in build with -p:PublishSingleFile=true #193

Open
varon opened this issue Jun 30, 2023 · 2 comments
Open

Comments

@varon
Copy link

varon commented Jun 30, 2023

I have encountered a hard crash inside your library due to use of reflection which is not available in a single file publish mode.

This should be very simple to solve.

System.TypeInitializationException: The type initializer for '<StartupCode$Ionide-ProjInfo-ProjectSystem>.$Environment' threw an exception.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
   at System.IO.Path.Combine(String path1, String path2)
   at <StartupCode$Ionide-ProjInfo-ProjectSystem>.$Environment..cctor() in /_//src/Ionide.ProjInfo.ProjectSystem/Environment.fs:line 148
   --- End of inner exception stack trace ---
   at Ionide.ProjInfo.ProjectSystem.Environment.get_dotnetSDKRoot()
   at FsAutoComplete.LspHelpers.FSharpConfig.get_Default() in src/FsAutoComplete/LspHelpers.fs:line 801
   at FsAutoComplete.Lsp.FSharpLspServer..ctor(State state, FSharpLspClient lspClient, ISourceTextFactory sourceTextFactory) in src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs:line 52
   at FsAutoComplete.Lsp.FSharpLspServerModule.startCore@3009-56.Invoke(FSharpLspClient lspClient) in src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs:line 3012

The precise issue occurs on line:

let dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)

Alternative approaches to achieve the same thing are available here: https://stackoverflow.com/questions/58428375/cannot-get-original-executable-path-for-net-core-3-0-single-file-ppublishsin

And the full documentation explaining the compatibility is here: https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli#api-incompatibility

@baronfel
Copy link
Collaborator

Would you be interested in submitting a PR to resolve this?

@varon
Copy link
Author

varon commented Jun 30, 2023

Unfortunately not at this time.

If I was working directly with ionide/proj info, sure - I only opened this up because I ran into a downstream issue with the F# LSP FsAutoComplete which I'm experimenting with, so don't have the code checked out and/or building on my side.

I'd also suggest that a change like this has the potential to be quite fiddly. There's probably various deployment scenarios to look out for, and someone experienced should definitely check this being fixed.

Sorry I can't be of direct help in solving this today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants