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

Specifying non-standard location dotnet install via DOTNET_ROOT not working #282

Closed
Sharpiro opened this issue Apr 18, 2024 · 6 comments · Fixed by #284
Closed

Specifying non-standard location dotnet install via DOTNET_ROOT not working #282

Sharpiro opened this issue Apr 18, 2024 · 6 comments · Fixed by #284

Comments

@Sharpiro
Copy link

Windows 10
dotnet 8

I have a dotnet install location that I have acquired from the zipped binaries that are made available.

I specified via environment variable DOTNET_ROOT that I want it pointed there. However, regardless of if I point it to a fresh dotnet 8 runtime or sdk install, I always get the error Failed to find an installed .NET host compatible with target version 8.0. It is indeed finding the install, as otherwise the error is different, but for whatever reason it deems it to be invalid.

I would ideally like to use the environment variable to point to a portable dotnet 8 runtime.

@jasongin
Copy link
Member

@Sharpiro, Can you set the environment variable NODE_API_TRACE_HOST=1, then capture the output? It includes some details about the process of finding and loading .NET.

@Sharpiro
Copy link
Author

I actually figured out the problem and the workaround is to ensure there are no hyphens in the dotnet root path.

int hyphenIndex = versionString.IndexOf('-');

This is problematic considering the default download of a portable dotnet install contains hyphens: dotnet-runtime-8.0.4-win-x64.

@jasongin
Copy link
Member

That line is meant to strip off an optional prerelease suffix from the version number. It is parsing only the version directories under $DOTNET_ROOT/host/fxr, so it shouldn't be handling any string of the form dotnet-runtime-8.0.4-win-x64.

string fxrDir = Path.Combine(dotnetRoot, "host", "fxr");
string[] versionDirs = Directory.GetDirectories(fxrDir);

When I extract dotnet-sdk-8.0.204-linux-x64.tar.gz, I only see an 8.0.4 directory under the host/fxr directory.

What is the value of your DOTNET_ROOT variable, and what directories do you see under $DOTNET_ROOT/host/fxr ?

@Sharpiro
Copy link
Author

Consider the scenario wheredotnetRoot and thus fxrDir is an absolute path, then the hyphen check will use the entire absolute path which may contain unexpected hyphens.

@jasongin
Copy link
Member

Oh, I see the problem is that code was assuming Directory.GetDirectories() returns just the simple directory names, but it returns full paths. I'll fix that.

@jasongin
Copy link
Member

Fixed in version 0.7.8. Packages should be published within a couple hours.

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

Successfully merging a pull request may close this issue.

2 participants