-
Notifications
You must be signed in to change notification settings - Fork 343
fix: use absolute node path in awf wrapper to survive sudo PATH stripping #25341
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -110,6 +110,12 @@ install_bundle() { | |||||||||||||||||||||
| local bundle_name="awf-bundle.js" | ||||||||||||||||||||||
| local bundle_url="${BASE_URL}/${bundle_name}" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Capture the absolute path to node so the wrapper works correctly when | ||||||||||||||||||||||
| # invoked via sudo (where PATH may not include the setup-node install dir, | ||||||||||||||||||||||
| # e.g. ~/.nvm/versions/node/v24.x.x/bin). | ||||||||||||||||||||||
| local node_bin | ||||||||||||||||||||||
| node_bin=$(command -v node) | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "Node.js >= 20 detected ($(node --version)), using lightweight bundle..." | ||||||||||||||||||||||
|
Comment on lines
+117
to
119
|
||||||||||||||||||||||
| node_bin=$(command -v node) | |
| echo "Node.js >= 20 detected ($(node --version)), using lightweight bundle..." | |
| node_bin=$(type -P node || true) | |
| if [[ -z "$node_bin" || ! -x "$node_bin" ]]; then | |
| echo "ERROR: Unable to resolve an executable absolute path for node" | |
| return 1 | |
| fi | |
| echo "Node.js >= 20 detected ($("$node_bin" --version)), using lightweight bundle..." |
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.
The \$@ escaping is correct for the unquoted heredoc — it ensures $@ is written literally into the wrapper script. Clear comment above explains this well. ✅
Copilot
AI
Apr 8, 2026
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.
The generated wrapper uses exec ${node_bin} ... without quoting. Even if uncommon, an unexpected path containing whitespace or glob characters would break execution due to word-splitting/globbing. Quote the node path in the wrapper (e.g., exec "${node_bin}" ...).
| exec ${node_bin} /usr/local/lib/awf/awf-bundle.js "\$@" | |
| exec "${node_bin}" /usr/local/lib/awf/awf-bundle.js "\$@" |
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.
The heredoc-expanded \$\{node_bin} correctly hard-codes the absolute node path into the wrapper script at creation time. The comment above (lines 136–138) explaining the unquoted heredoc (<<WRAPPER) vs a quoted one (<<'WRAPPER') is clear and helpful for future maintainers.
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 fix — capturing
node_binwithcommand -v nodeat wrapper-creation time is the right approach. Consider adding a guard here in casenodeisn't on PATH yet when this function runs, e.g.if [[ -z "$node_bin" ]]; then echo "ERROR: node not found" >&2; return 1; fi.