-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
.NET Core executables fail if .NET Core is not installed in default location #9304
Comments
Possible solution: the apphost should automatically default DOTNET_ROOT to the first dotnet.exe on PATH. |
This is by design and the decision we made on the host taking many different things in consideration. I believe the dotnet install message will guide you to setting DOTNET_ROOT if your dotnet is not installed in the default location. |
My concern about this design is that the error message is not clear when there are some .NET Core runtime installations in C:\Program Files\dotnet, but not the right ones for the global tool. How would a user ever figure this out from this?
|
@steveharter is this something that we could improve in the host? |
The error message could be extended to provide more information, but is really a short-term problem since once the hostfxr should be updated (once) it should be good forever for this particular error message.
I'd prefer not to start probing %PATH% |
Can you elaborate? It seems like it would be a better user experience, but want to know why you would rather not. I was expecting this PATH lookup behavior because it's one we depend on to make Visual Studio work SDKs installed into user-locations. It's also one less variable that we have to set to make CI builds work well. We already have a handful, and the list seems to be ever growing. |
Probing %PATH% for dotnet.exe is not intuitive and somewhat error-prone as we can't exactly duplicate what the OS does. That's why we added %DOTNET_ROOT% |
I filed the same issue for Linux: https://github.com/dotnet/core-setup/issues/4078. I have the same expectation as @natemcmaster: CC @eerhardt @dleeapho @omajid An alternative solution (https://github.com/dotnet/core-setup/issues/4078#issuecomment-384653329) is to allow source-build to specify the 'default' location. That would fix the source-build case, but not @natemcmaster's case. This would still require setting DOTNET_ROOT. Perhaps we can use this fallback order: DOTNET_ROOT, PATH probing, hard-coded path. A pseudo Unix implementation for finding the root via PATH:
|
Aren't there other things already looking for dotnet.exe on the %PATH%? This could lead to situations where |
Independent of implementation, a user expects this to work:
|
The issue I have with probing the Now, the In my opinion it conflates the job/purpose of the That's why we introduced a new environment variable that serves a single purpose - locating the "dotnet hive". |
@eerhardt what do you think about this order then: DOTNET_ROOT, hard-coded path, PATH probing.
|
A agree with what @tmds said. It was my expectation that after To @eerhardt's points:
I understand the engineering purity of this argument, but think there is another compelling point to consider. PATH probing is consistent with how the rest of the product behaves. Over the last few years, we have been teaching people that you can install .NET Core into a custom location. If you put it on PATH first, Visual Studio, VS Code, MSBuild.exe, and the command line will use that custom install location. The current behavior of global tools breaks from this pattern. And from what I'm hearing, the reasons for breaking from that pattern seem to be narrowly focused on what the apphost should do, not on the behavior of the .NET Core product as a whole.
I agree with you here. I would not expect dotnet-serve to find /path/to/dotnet. That said, I'm not asking this. I'm asking for PATH probing. Let me be completely clear why this is so maddening to me. The majority of .NET Core tools today are written so they can be invoked as |
Concerns
That said, I agree that the scenario is real and proposed solution has merit. We did consider this during the design phase, I can PM you that link. However, that discussion for %PATH% was not considered as a last-resort fallback at the time; instead it was competing with %DOTNET_ROOT% as the primary mechanism. |
On Linux this is implemented in user-space. For example, corefx implementation is here: https://github.com/dotnet/corefx/blob/9bfa3bd511a6a2152de8192332b0e439917e65e0/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs#L480-L498
A lot of things get probed (executable on PATH, libraries on LD_LIBRARY_PATH, ...) and we don't perceive slowness. The earlier on PATH, the sooner the match.
Using data from PATH is as secure as using data from DOTNET_ROOT.
For the reasons explained by @natemcmaster my preferred order is DOTNET_ROOT, PATH probing, hard-coded path For source-build, we want to be able to set the hard-coded path. If path probing is implemented, we can rely on that for now. If there is no path probing, we need to make the hard-coded path a setting that can be specified from source-build. |
same issue with if i do:
the install is ok but doesnt works running it directly with
As a note, that installed is higher priority in setting |
@richlander @KathleenDollard can you chime in please? |
This is a real issue. We discussed it when we were designing global tools. We didn't discuss the point that @natemcmaster raised on installation and execution of a tool not agreeing on .NET Core location. That's a real challenge. I'm not going to propose anything just yet, but need to information collect a bit more.
Can someone point me to the code that does this? |
as a note.
But both are broken, also direct run of the .exe:
at least the second should work. seetting the
but the |
@richlander do you have an update? |
One of the key side-by-side promises of .NET Core was that you could just run an executable from a folder and add things to the PATH, it would be very nice if global tools would follow this approach. If the PATH was probed as a last resort fallback then it may not be a breaking change after 2.1.300 and could maybe be done for 2.1.400? It would only enable things that would not have worked before anyway and wouldn't break things that used to work before. |
We are working on trying to find alternatives to improve this scenario. I will post back once we know more. |
I'm comparing the gobal tools with npm tools.
@livarcocc @richlander if you are changing the design of this, please consider doing a https://github.com/dotnet/designs. |
I seem to be running into this after upgrading to 2.1 on Arch Linux and attempting to use EF Core migrations. Because migrations are now implemented as a global tool, I receive a message instructing me to install it:
But when trying to install it, I get this message. I tried to set
|
@Welkie the layout under DOTNET_ROOT should be like this. The directory that has the dotnet executable but not the symbol link
|
This finds dotnet on PATH and determines DOTNET_ROOT based on that: export DOTNET_ROOT=$(dirname $(realpath $(which dotnet))) |
Python solves this problem by putting tool executables into a folder that is inside the Python installation directory. So every installation can have its own set or tools. Wouldn't it possible to do this as well for custom Core installations? E.g. put the tools into folder inside the folder that has the dotnet executable. Tools would then look up and check if there's a dotnet that they can use and otherwise fall back to a global path. |
the azure agent doesnt set DOTNET_ROOT and global tools doesnt work ref https://github.com/Microsoft/azure-pipelines-image-generation/issues/531 ref https://github.com/dotnet/cli/issues/9114
Set up CI with Azure Pipelines, replace Travis and Appveyor The OSX CI is not added because the azure agent for OSX doesnt set DOTNET_ROOT and global tools doesnt works, so a test fails ref https://github.com/Microsoft/azure-pipelines-image-generation/issues/531 ref https://github.com/dotnet/cli/issues/9114 The scala tests are ignored too, because sbt is not installed in the azure agent
Set up CI with Azure Pipelines, replace Travis and Appveyor The OSX CI is not added because the azure agent for OSX doesnt set DOTNET_ROOT and global tools doesnt works, so a test fails ref https://github.com/Microsoft/azure-pipelines-image-generation/issues/531 ref https://github.com/dotnet/cli/issues/9114 The scala tests are ignored too, because sbt is not installed in the azure agent
* integrated Incrementalist into build pipeline * added workaround for https://github.com/dotnet/cli/issues/9114 * added option to skip builds entirely if no code changes found
I'm still getting this error on Azure Pipelines macOS even with DOTNET_ROOT set:
Result:
What options are there? |
Try changing this line to include export DOTNET_ROOT="$(dirname "$(readlink "$(command -v dotnet)")")" |
@natemcmaster Thank you! That works. |
* integrated Incrementalist into build pipeline * added workaround for https://github.com/dotnet/cli/issues/9114 * added option to skip builds entirely if no code changes found
* integrated Incrementalist into build pipeline * added workaround for https://github.com/dotnet/cli/issues/9114 * added option to skip builds entirely if no code changes found
as a user who just supports dev teams I can't express how much confusion and frustration dotnet CLI causes. There's so much mess. We use the dotnet install scripts (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script) on Linux and making this all work with multiple frameworks/cli versions is just a mess. Please improve so we don't have to waste time getting seemingly simple things like "dotnet tool" to work. |
When the shim is created, the path for the target dll is set in the apphost template. |
For those using the snap package, the
Complete configuration for Ubuntu development:
|
I just want to add an anecdote I encountered that caused me a huge amount of confusion, and no amount of I work at a bank and we don't have admin access to our machines. To not have to deal with the pain that it is getting someone to install .net core 3.0 for me I downloaded the binaries, placed them in However, I downloaded Linqpad6 (which is a .net core 3.0 application) and it would not run. Running the executable would do absolutely nothing, and trying to After a back and forth with the Linqpad dev I ended up doing a really round about testing that finally gave me the error above about the So my point is, this has the potential to really cause confusion for downloaded .net core precompiled binaries and it's actually very hard to find out that the solution is At a minimum I believe that if |
This issue was moved to dotnet/core-setup#8570 |
core-setup is the more appropriate repo. |
You know GitHub let's you transfer issues instead of just copying to a new one, right? |
had the same issue while creating a dockerfile for node + pwsh
thx alot |
I am so lucky to have the awesome people happened to use Ubuntu 18.04 & Snap just as I did. God knows how much time I could spend more on this after a simple automatic update. |
I think the best solution for this for tools is to publish the tools as self contained and packaged as self contained (but somehow without an apphost or somehow with an apphost that works for all OS's using RID specific tool packages). |
Steps to reproduce
Download .NET Core CLI to $env:USERPROFILE/.dotnet/x64 and install a global tool
Expected behavior
The generated shim dotnet-serve.exe should find and use the dotnet on PATH to launch the global tool.
Actual behavior
If no .NET Core is installed in
C:\Program Files\dotnet
If .NET Core is installed in
C:\Program Files\dotnet
, but doesn't have the right shared framework versionEnvironment data
dotnet --info
output:The text was updated successfully, but these errors were encountered: