hensou / asdf-dotnet

dotnet (.net) plugin for asdf version manager
MIT License
42 stars 10 forks source link

Document incompatibility with MSBuildLocator #6

Closed hochata closed 1 year ago

hochata commented 1 year ago

Describe the bug

I tried to run csharp-ls and failed with a very cryptic error. I turns out the error was caused by the ASDF shim not being the real dotnet executable.

Steps to reproduce

Details here.

Expected behavior

Code-wise there isn't anything to do. ASDF shims and the MSBuildLocator are just incompatible. But maybe this behavior could be documented here to prevent newbies like me from getting lost in the cryptic stack-traces.

hensou commented 1 year ago

@hochata thanks for taking time to report that. I'll have a deeper look soon.

But just from a quick look at it, looks like it's something bigger than the shim thing.

https://github.com/dotnet/roslyn/issues/67383 https://github.com/dotnet/runtime/blob/main/docs/design/features/native-hosting.md

hochata commented 1 year ago

Henrique Sousa @.***> writes:

@hochata thanks for taking time to report that. I'll have a deeper look soon.

But just from a quick look at it, looks like it's something bigger than the shim thing.

dotnet/roslyn#67383

Yes, by the looks of it, their heuristics are not very accurate. I don't think there is much to do in this plugin, just wait for the library to improve. Maybe contribute to their discussions.

I just thought it would be nice to at least have it documented it somewhere :)

hensou commented 1 year ago

@hochata, I was investigating this further, I found some interesting things:

Now I'll try to see if there is some environment variable missing that could help with this issue.

In the meantime I updated the docs as you suggested, let me know if there are more details that would be nice to have on it.

hensou commented 1 year ago

It seems that the root cause is this https://github.com/microsoft/MSBuildLocator/issues/210 and it seems that csharp-ls uses a version of MSBuildLocator that is >= 1.5.3

Maybe a fix would be to force the library path with the linker, as stated at https://github.com/dotnet/format/issues/1785

Now the odd thing is that, if I manually run csharp-ls it does find the asdf installation.

hochata commented 1 year ago

Last time I tried I got an error with Omnisharp.

I will trry again and report anything I find.

Thanks for taking your time to solve this!

hochata commented 1 year ago

I tried using a symlink as stated, but it fails with the same error.

hensou commented 1 year ago

Can you provide information on what editor you use and how you configured omnisharp? I wanted to reproduce it on my side. With csharp-ls it does fail, but omnisharp works for me

hochata commented 1 year ago

Sorry, the failure is probably another unrelated mistake on my part. I can't get it to work even with the officially installed SDK.

But this reminds me that Omnisharp doesn't use the .NET SDK, it requires the Mono one. And from the logs, it also uses Mono MSBuild. Maybe it doens't get affected by the bug you decribed?

I can try with the Ionide server to see if anything is different.

hochata commented 1 year ago

I could get Omnisharp working with ASDF after installing the Mono version of MSBuild.

I doesn't suffer from the bug you found, but maybe it is because it is using an unaffected version.