Closed Jiehong closed 1 year ago
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
Author: | Jiehong |
---|---|
Assignees: | - |
Labels: | `area-System.Net`, `untriaged` |
Milestone: | - |
That its unfortunate. I think the code does not follow PATH on purpose to avoid executing something unintentional.
I think we may be able to add /run/current-system/sw/bin
but I'm not sure we want to fiddle with unusual behavior of nix-shell
.
Workaround may be running app in a way that has access to raw sockets or execute the ping directly.
@wfurt : I think that you're right, just adding /run/current-system/sw/bin
should be sufficient most of the time for NixOS
Description
.NET, and by extension powershell, cannot find the
ping
command on NixOS, because it doesn't respect the PATH variable.This breaks powershell's Test-Connection cmdlet.
Reproduction Steps
I discovered this issue while using powershell 7.2 in NixOS:
Checking the error:
However, running
ping localhost
in powershell directly works just fine.Expected behavior
.NET should find "ping" without issues, no matter where it is.
It seems to have special places only where it will look for stuff: https://github.com/dotnet/runtime/blob/6407eae2c9cda49c725e744f9628bca65b6e71d2/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs#L13
But on NixOS, it's not there:
But this is a special case only for some commands.
In general, NixOS links commands in
/run/current-system/sw/bin
(ping
is there as expected):Solutions
/run/current-system/sw/bin
for NixOS (PARTIAL SOLUTION ONLY)Limitation: if running in a
nix-shell
environment, this won't work, because nix will add the command in the PATH only, and the actual path cannot be determined!For example,
nix-shell -p dbeaver
generates a subshell in whichdbeaver
is available, but its path is/nix/store/75g823zvwj061w0q3amw8260s689cvd8-dbeaver-22.2.2/bin/dbeaver
, and it's only available becausePATH
has been modified accordingly. That's just how nixos works.Actual behavior
ping is not found, and Test-Connection fails.
Regression?
Unknown
Known Workarounds
No response
Configuration
Other information
No response