Use "command -v" instead of "which" to detect commands#1419
Merged
sbc100 merged 2 commits intoemscripten-core:mainfrom Jul 1, 2024
Merged
Use "command -v" instead of "which" to detect commands#1419sbc100 merged 2 commits intoemscripten-core:mainfrom
sbc100 merged 2 commits intoemscripten-core:mainfrom
Conversation
On a Linux distro that doesn't have the `which` program installed we're getting the following error:
./emsdk install latest
./emsdk: line 39: exec: python: not found
It's failing to detect the installed `python3` and falls back to using `python`, but this distro doesn't provide a python -> python3 symlink so we fail.
Fix this by using `command -v` instead which is a POSIX standard.
The same change went into emscripten a couple years ago: emscripten-core/emscripten#15071
sbc100
reviewed
Jun 28, 2024
| # https://github.com/emscripten-core/emsdk/pull/273) | ||
| if [ -z "$EMSDK_PYTHON" ]; then | ||
| if PYTHON3="$(which python3 2>/dev/null)"; then | ||
| if PYTHON3="$(command -v python3 2>/dev/null)"; then |
Collaborator
There was a problem hiding this comment.
I think all the other changes apart from this line can be reverted.
This is the only place where the code really needs to be portable and run on many different distros. All the other places are basically build scripts where we control the environment.
sbc100
approved these changes
Jun 28, 2024
Collaborator
sbc100
left a comment
There was a problem hiding this comment.
lgtm, with a limiting of the scope of this change.
Contributor
|
I think this is fine for now, but eventually it would be good to migrate to |
sbc100
approved these changes
Jul 1, 2024
mmorel-35
pushed a commit
to mmorel-35/emsdk
that referenced
this pull request
Feb 3, 2026
…ripten-core#1419) On a Linux distro that doesn't have the `which` program installed we're getting the following error: $ ./emsdk install latest ./emsdk: line 39: exec: python: not found It's failing to detect the installed `python3` and falls back to using `python`, but this distro doesn't provide a python -> python3 symlink so we fail. Fix this by using `command -v` instead which is a POSIX standard. The same change went into emscripten a couple years ago: emscripten-core/emscripten#15071
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a Linux distro that doesn't have the
whichprogram installed we're getting the following error:It's failing to detect the installed
python3and falls back to usingpython, but this distro doesn't provide a python -> python3 symlink so we fail.Fix this by using
command -vinstead which is a POSIX standard.The same change went into emscripten a couple years ago: emscripten-core/emscripten#15071