-
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
Global tools path not discoverable on macOS via which
#10177
Comments
You need to restart your shell for the PATH changes to take effect. Have you tried that? Otherwise, it would be good to know which shell you are using. cc @wli3 |
I guess in the steps to reproduce the problem, I should have added “restart shell” after installing the SDK, but yes, I did do that.
I am using Bash in the macOS Terminal:
|
I think it is related to https://github.com/dotnet/core-setup/issues/5099#issuecomment-476010399 There is no other way to put a user path on $PATH using PATH_HELPER for every user (that I can find). |
The bigger (and related) problem here is that private static string FindProgramInPath(string program)
{
string path;
string pathEnvVar = Environment.GetEnvironmentVariable("PATH");
if (pathEnvVar != null)
{
var pathParser = new StringParser(pathEnvVar, ':', skipEmpty: true);
while (pathParser.MoveNext())
{
string subPath = pathParser.ExtractCurrent();
path = Path.Combine(subPath, program);
if (File.Exists(path))
{
return path;
}
}
}
return null;
} |
@atifaziz that I am not sure. If you just type the command name, it is resolved by the shell. dotnet should not be in the picture yet. The code above is used in process.start which is not used in run command. |
Yes but is that the only experience we are optimising for? It seems odd that while shell can launch, other programs like For example, create a new console application with using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
static class Program
{
static int Main(string[] args)
{
var psi = new ProcessStartInfo(args[0])
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
foreach (var arg in args.Skip(1))
psi.ArgumentList.Add(arg);
using (var process = Process.Start(psi))
{
process.OutputDataReceived += (_, ea) =>
{
if (ea.Data != null)
Console.WriteLine(ea.Data);
};
process.ErrorDataReceived += (_, ea) =>
{
if (ea.Data != null)
Console.Error.WriteLine(ea.Data);
};
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
return process.ExitCode;
}
}
} Next use the program to launch any globally installed tool on macOS, e.g.:
|
Ran into the same issue on macOS Big Sur (v11.1) with the new default Terminal shell, zsh (v5.8), while trying to use a new CLI tool. I tried closing and starting a new Terminal command line window and restarting Terminal entirely, all without any luck. % dotnet tool install WildernessLabs.Meadow.CLI --global
Tool 'wildernesslabs.meadow.cli' is already installed.
% meadow --Download
zsh: command not found: meadow I could only work around it by "fully qualifying" the path using the information on this troubleshooting page. % $HOME/.dotnet/tools/meadow --Download |
Monterey, too, in ZSH. Would love to see this get fixed. |
It's likely covered in some of the related issues, but here's what worked for me, if anyone else needs a workaround for this issue in zsh. After you install the SDK, add the global install tools folder to export PATH="$PATH:$HOME/.dotnet/tools" |
Steps to reproduce
which
in a Terminal session on macOS to discover the tool's pathExpected behavior
which
should print the absolute path of where the global tool is installed and finish with an exit code of zero.Actual behavior
which
fails with a non-zero exit code.Environment data
My
PATH
contains the path to the tools directory:Running
dotnet --info
prints:The text was updated successfully, but these errors were encountered: