-
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
Cannot run global tool after installing it, must open new command prompt #8999
Comments
Did you just installed SDK? It requires a restart of command prompt in order for PATH in registry to work. However there should be an error message to tell the user to restart. |
@danroth27 can you give us the info @wli3 is asking for above? |
We could either add these windows specific code or add instruction to reopen cmd |
Yes, opening a new command prompt works, but I don't think that's the user experience we want. You should be able to install a global tool and use it immediately. That's how npm global tools work, right? /cc @KathleenDollard |
This is only a problem for when dotnet is first installed and I believe is a similar behavior as npm actually. It is not a matter of I ran install or not. It is a matter of I just got this CLI. |
Oh, so this is a one time thing? |
one time per user |
Ah, ok. I think that's fine then. |
Will can you put the new text in this issue? I think it would tidy up this issue prior to closing it. We updated that "If there are no further instructions" and I thought it was a but more clear in the install that the restart was needed. |
I haven't put the change in yet. According to https://github.com/dotnet/cli/issues/8369 We want to use the following
|
Cool, that will the new text be in Preview 1? |
No, it won't be in preview 1. But that's what we decided so far. Do we want to add more to it according to this thread? |
@KathleenDollard Above is not in preview 1. What in preview 1 is issue description's version. |
could something be done to test if the directory that the shim was written to is not yet on the current |
@dasMulli Something similar is added. However, I think it is not working properly due to, in Windows it cannot distinguish between what will be available(in registry) and what is available in the session |
With official preview release (macOS): dotnet install tool dotnet-dev-certs -g --version 2.1.0-preview1-final
Since you just installed the .NET Core SDK, you will need to reopen terminal before running the tool you installed.
The installation succeeded. If there are no further instructions, you can type the following command in shell directly to invoke: dotnet-dev-certs and: dotnet-dev-certs
command not found: dotnet-dev-certs I'd suggest to rephrase it to |
I've the same error when using My command is like: dotnet tool install --global dotnet-sonarscanner This command outputs this: Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.
You can invoke the tool using the following command: dotnet-sonarscanner
Tool 'dotnet-sonarscanner' (version '4.3.1') was successfully installed. And the next step will fail (running the above command in the same step or a different script step make no difference)
|
If you just installed the SDK, the path to your global tools you need to restart the shell for the path to global tools to be recognized. Are you installing and running via a script? (where this would be quite problematic) If so @wli3 can he set the path explicitly in the script to avoid the problem? |
You could add |
+1 for the tool path. an example vsts / azure pipelines config usage can bee seen in msbuild: |
Hi @dasMulli ; keep seeing you everywhere... For now I just solved it by providing the full path to the executable, so:
See also linked issue microsoft/azure-pipelines-tasks#8291 |
Some problem here . However, in old VSTS pipelines it works. It Azure DevOps it does not. |
@ignatandrei Same here. VSTS Pipeline stopped working -- unable to find the tool installed in a previous step. |
@cosmoKenney : After reporting as a bug (https://developercommunity.visualstudio.com/content/problem/340067/install-global-tool.html?childToView=343864#comment-343864 ) , found an workaround until the bug is solved: See the https://github.com/ignatandrei/stankins/blob/master/azure-pipelines.yml steps:
( I do prefer putting on current dir rather to be based on %USERPROFILE%.dotnet\tools\ folder that can change at a future release . It is still a workaround) |
@ignatandrei I really don't understand the yaml. Did you switch to a CMD task? |
Yes. |
@wli3 in an automated scenario like Azure pipelines(previously VSTS) this is a big problem. There is no way to open a new shell to mitigate this. Also, just adding a better message does not solve this problem. Why does dotnet tool require this extra manual step? Npm works just fine. At the minimum, |
+1 on reopening this issue. Using the CMD step [workaround] to install the tool using --tool-path doesn't work if you install a tool to some arbitrary folder. Then if you use the tool in a following step in the pipeline, you still don't have access to the tool. If there were a variable you could use with a path in both steps that would help mitigate the issue. |
Sorry, it's a bit unclear whether the original complaint was ever addressed. Does dotnet now set the PATH correctly for globally installed tools in the original scenario, or must we instead use |
@dbsanfte The problem with needing to restart the shell is in how some shell/OS's work. That waste original issue. This only needs to be done once, after installing the .NET SDK. I'm not sure that's the issue you're referring to. |
What if I cannot restart? I'm using a Dockerfile to build an AZP agent... |
I am facing the same issue: I'm in a Docker container, at build time on our build server. @KathleenDollard It should be trivial to update the PATH of the current shell session in addition to the system one. |
This is actually not trivial by the design of Unix. PATH like any other environment variable is stored in current shell session. There is no API available to change PATH in an application for the current session. However, if you are in Docker you could run |
You're right actually, on second thought it isn't so trivial. I'm fine with sourcing .bashrc if that's where you're updating my PATH. Still kind of sucks though. |
@dbsanfte We'd love to have a better experience on this and remain open to ideas. But we're also committed to playing nice on all the platforms we support. |
@dbsanfte we did not add the export to bashrc. it is in |
Can you make a symbolic link in /usr/local/bin? That's in most everyone's PATH, definitely the default PATH in Ubuntu at any rate. helm, kubectl, tiller, etc put their symbolic links there. |
That would require |
For a global install (presumably for all users), sudo would seem to be acceptable. |
as a AzureDevOps user creating a CI/CD pipeline or creating a global tool that is to be used in a AzureDevOps pipeline guidance is needed on why/how/what steps are required & the order of these steps to allow tools to work as expected. |
Agreed with @3GDXC, I can't seem to find good guidance here. |
Hey @adamtuliper, please check the following script block from my latest pipeline: - script: >-
dotnet tool install dotnet-reportgenerator-globaltool
--global
--version $(ReportGenerator_Version)
name: 'install_code_coverage_report_generator'
displayName: 'Install code coverage report generator tool'
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: $(DotNetSkipFirstTimeExperience)
DOTNET_CLI_TELEMETRY_OPTOUT: $(DotNetCliTelemetryOptOut)
COREHOST_TRACE: $(CoreHostTrace) I no longer use the |
@satrapu Thanks for that. Having another way is good to know. There's a catch in what you wrote above, it is working as a byproduct of the .NET Core install by updating PATH. It just so happens you are doing a specific version install to make that happen rather than exporting the tools folder to the path. One thing to consider - outside of that workaround a local tools folder may be faster and easier than managing/updating version information and an additional SDK install task. I can simplify by using a local tool, your scenario may not allow that though.
vs
|
Also having this issue with a custom tool that I built. my tol doesn't run properly when ran from the initial global install prompt, but if I close out and go to a new powershell/terminal/command prompt it works just fine. Any known solutions here? |
IDK why this issued has been closed. It still doesn't work in an Azure pipeline, e.g. I can't run AzureSignTool:
For now, using
Updated for those who may end up here, like me again in 2023. Eventually, instead of For example:
This creates/updates the local file {
"version": 1,
"isRoot": true,
"tools": {
"azuresigntool": {
"version": "4.0.1",
"commands": [
"azuresigntool"
]
}
}
}
I'm using this approach in my project's CI/CD pipleline and it gives me reliable & reproducible builds. |
After I have successfully installed a global tool I am not able to run it without opening a new command prompt:
The text was updated successfully, but these errors were encountered: