Use POSIX "command" instead of non-standard "which" #8823
Use POSIX "command" instead of non-standard "which" #8823
Conversation
GNU which might not be installed on a minimal GNU/Linux installation. Refs dotnet#6994 and dotnet#7025.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
I believe the only flaw in the prior PR for this (which broke the official build) was that it should have been getting the full path for the two variables CC and CXX. I wasn't able to verify that at the time though, and because nobody needed this until now, it fell low on my list of priorities 😄. The reason for using hash was to maintain consistency with other places where we use it for checking whether commands exist. That said, I'm okay with this change if it works. |
@@ -110,8 +110,7 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then | |||
__DOTNET_LOCATION="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz" | |||
# curl has HTTPS CA trust-issues less often than wget, so lets try that first. | |||
echo "Installing '${__DOTNET_LOCATION}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log | |||
which curl > /dev/null 2> /dev/null | |||
if [ $? -ne 0 ]; then | |||
if command -v curl > /dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks backwards to me, and the official builds seem to have tried to use wget
when the machine should use curl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, Sorry:I just wanted to cleanup non-idiomatic shell-code while doing the which->curl change. I will never merge multiple changes in one commit again
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I can see how easy it would be to mix up those changes. It will be nice to have the more idiomatic/straight forward approach from now on.
My thought on why this passed CI is that CI machines might happen to have @dleeapho FYI on an interesting case that CI/official prereq disparity can cause. |
`which` is an external utility. `hash` or `command -v` are built-in General Commands. See http://stackoverflow.com/a/677212/863980 Related: dotnet/coreclr#8823 & dotnet/corert#2831 I chose `hash` here as `run-build.sh` is already using it.
`which` is an external utility. `hash` or `command -v` are built-in General Commands. See http://stackoverflow.com/a/677212/863980 Related: dotnet/coreclr#8823 & dotnet/corert#2831 I chose `hash` here as `run-build.sh` is already using it.
Use the POSIX built-in 'command' instead of 'which'; the latter may not be available on all platforms, and not all implementations have the same behavior. This change is similar to dotnet/coreclr#8823.
Ported majority of the functionality from build.cmd to build.sh to make it easier to build/run the various test suites. The usual 'net40' projects build just fine, but some of the projects in the test suites seem to have build errors unrelated to build.sh. Accept but ignore 'ci' target for now. The mono distribution for Linux doesn't seem to include nuget as it does on macOS. Try to use built-in nuget but fall back to the binary in the repo if necessary. Use the POSIX built-in 'command' instead of 'which'; the latter may not be available on all platforms, and not all implementations have the same behavior. (See dotnet/coreclr#8823 for a similar change.)
Ported majority of the functionality from build.cmd to build.sh to make it easier to build/run the various test suites. The usual 'net40' projects build just fine, but some of the projects in the test suites seem to have build errors unrelated to build.sh. Accept but ignore 'ci' target for now. The mono distribution for Linux doesn't seem to include nuget as it does on macOS. Try to use built-in nuget but fall back to the binary in the repo if necessary. Use the POSIX built-in 'command' instead of 'which'; the latter may not be available on all platforms, and not all implementations have the same behavior. (See dotnet/coreclr#8823 for a similar change.)
Ported majority of the functionality from build.cmd to build.sh to make it easier to build/run the various test suites. The usual 'net40' projects build just fine, but some of the projects in the test suites seem to have build errors unrelated to build.sh. Accept but ignore 'ci' target for now. The mono distribution for Linux doesn't seem to include nuget as it does on macOS. Try to use built-in nuget but fall back to the binary in the repo if necessary. Use the POSIX built-in 'command' instead of 'which'; the latter may not be available on all platforms, and not all implementations have the same behavior. (See dotnet/coreclr#8823 for a similar change.)
) GNU which might not be installed on a minimal GNU/Linux installation. Refs dotnet/coreclr#6994 and dotnet/coreclr#7025. Commit migrated from dotnet/coreclr@7f8557f
GNU
which
might not be installed on a minimal GNU/Linux installation.It's also not listed in the building instructions
Build failed on my Arch Linux base install without error messages (
stderr
is redirected to/dev/null
) because of the missing GNUwhich
command even thoughpython
is installed:There is no need to use
which
because every POSIX shell provides command to get the pathname of a command.I know there was already a try and revert
I don't know why it was reverted/broke the build. Maybe because the original author @adityamandaleeka used
hash
which has a different purpose (caching/manipulating command locations).