fix: Handle undefined VERSION in installer script#1512
Merged
drager merged 2 commits intodrager:masterfrom Jul 24, 2025
Merged
Conversation
## Issue Description The wasm-pack installer script fails in CI environments with the error: ./install.sh: line 18: VERSION: unbound variable This occurs when running the standard installation command: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh ### Root Cause The script uses 'set -u' on line 16, which causes bash to exit on undefined variables. Line 18 then references $VERSION before it's defined: UPDATE_ROOT="https://github.com/rustwasm/wasm-pack/releases/download/$VERSION" The script expects VERSION to be set as an environment variable, but this is not documented and is impractical in many CI environments where the command is piped directly to sh. ### Affected Environments - GitHub Actions - GitLab CI - Jenkins - Any environment where setting env vars before piping is difficult ### Fix This commit adds proper VERSION handling: 1. Check if VERSION is already set as an environment variable 2. Parse --version from command line arguments 3. Default to 'latest' if not specified 4. Resolve 'latest' to actual version via GitHub API 5. Ensure VERSION has 'v' prefix for download URLs ### Compatibility Maintains full backward compatibility: - VERSION=0.13.1 curl ... | sh (still works) - curl ... | sh -s -- --version 0.13.1 (new) - curl ... | sh (defaults to latest) This allows the installer to work in all environments without requiring users to modify their CI scripts to set environment variables.
Contributor
Author
|
Linux-stable test failing is unrelated to this PR. This PR only modifies the bash installer script and shouldn't affect cargo-test. |
drager
reviewed
Jul 24, 2025
docs/_installer/init.sh
Outdated
|
|
||
| # Resolve "latest" to actual version number | ||
| if [ "$VERSION" = "latest" ]; then | ||
| VERSION=$(curl -s https://api.github.com/repos/rustwasm/wasm-pack/releases/latest | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/') |
Owner
There was a problem hiding this comment.
This will now result in a 404 since the rustwasm org no longer exists.
Contributor
Author
There was a problem hiding this comment.
https://blog.rust-lang.org/inside-rust/2025/07/21/sunsetting-the-rustwasm-github-org/
Ah ok I didn't see this blog post. Updated to point at this repository.. Feel free to take over this PR btw.
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.
Issue Description
The wasm-pack installer script fails in CI environments with the error:
./install.sh: line 18: VERSION: unbound variable
This occurs when running the standard installation command:
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
Root Cause
The script uses 'set -u' on line 16, which causes bash to exit on undefined variables. Line 18 then references $VERSION before it's defined:
UPDATE_ROOT="https://github.com/rustwasm/wasm-pack/releases/download/$VERSION"
The script expects VERSION to be set as an environment variable, but this is not documented and is impractical in many CI environments where the command is piped directly to sh.
Affected Environments
Fix
This commit adds proper VERSION handling:
Compatibility
Maintains full backward compatibility:
This allows the installer to work in all environments without requiring users to modify their CI scripts to set environment variables.