fix: stop a piped install.sh from silently skipping the install - #63
Merged
Conversation
install.sh is documented to be run as `curl ... | bash`, where the script text is itself standard input. A child process that reads stdin therefore consumes the rest of the script, after which bash reaches EOF and exits 0 -- having skipped everything that had not been read yet, and reporting success. That is what `sudo -u "$SUDO_USER" brew install` did. With --install-deps on macOS the prerequisites were installed, the script ended there, and libquil was never downloaded. The step passed; the failure surfaced later and elsewhere, as HeaderNotFound in libquil-sys's build script, because /usr/local/include/libquil did not exist. See rigetti/libquil-sys#68. Every command that could read stdin now gets </dev/null: both brew calls, the two apt-get calls, and unzip, which prompts on an existing file. The script cannot simply redirect its own stdin, because bash is still reading itself from there. This is a regression from replacing the consumers' wrapper scripts with a direct `curl ... | bash`. Those wrappers downloaded the installer to a temporary file and ran it from disk, which never had this problem. Verified by piping the script into bash: it now runs to completion and installs all seven files, where the shape of the old failure is reproducible with any stdin-reading child.
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.
install.sh is documented to be run as
curl ... | bash, where the script text is itself standard input. A child process that reads stdin therefore consumes the rest of the script, after which bash reaches EOF and exits 0 -- having skipped everything that had not been read yet, and reporting success.That is what
sudo -u "$SUDO_USER" brew installdid. With --install-deps on macOS the prerequisites were installed, the script ended there, and libquil was never downloaded. The step passed; the failure surfaced later and elsewhere, as HeaderNotFound in libquil-sys's build script, because /usr/local/include/libquil did not exist. See rigetti/libquil-sys#68.Every command that could read stdin now gets </dev/null: both brew calls, the two apt-get calls, and unzip, which prompts on an existing file. The script cannot simply redirect its own stdin, because bash is still reading itself from there.
This is a regression from replacing the consumers' wrapper scripts with a direct
curl ... | bash. Those wrappers downloaded the installer to a temporary file and ran it from disk, which never had this problem.Verified by piping the script into bash: it now runs to completion and installs all seven files, where the shape of the old failure is reproducible with any stdin-reading child.