Skip to content

fix: error when install path does not exist#2982

Open
waveywaves wants to merge 2 commits intochainloop-dev:mainfrom
waveywaves:fix/install-path-error-output
Open

fix: error when install path does not exist#2982
waveywaves wants to merge 2 commits intochainloop-dev:mainfrom
waveywaves:fix/install-path-error-output

Conversation

@waveywaves
Copy link
Copy Markdown
Contributor

Summary

  • Add install.sh to the main repository (migrated from the now-archived chainloop-dev/docs repo at static/install.sh) with two bug fixes:
    • Early path validation: Check that the --path installation directory exists before downloading anything, with a clear error message and actionable suggestion (mkdir -p)
    • Better install error reporting: Replace silent 2>/dev/null stderr suppression in the install step with proper error handling and user-facing messages

Note: The install script was previously hosted only in the archived chainloop-dev/docs repo and served via dl.chainloop.dev. The CDN/deployment pipeline will need to be updated to serve this script from the new location.

Fixes #2977

Test plan

  • Run bash install.sh --path /nonexistent/path and verify it exits early with: The installation path '/nonexistent/path' does not exist. Please create it first with: mkdir -p /nonexistent/path
  • Run bash install.sh --path /tmp/test-install (after mkdir -p /tmp/test-install) and verify normal installation succeeds
  • Run bash install.sh with default path (/usr/local/bin) and verify existing behavior is preserved
  • Verify install failure (e.g., permission denied to a read-only directory) produces a meaningful error instead of silent failure

🤖 Generated with Claude Code

@waveywaves waveywaves force-pushed the fix/install-path-error-output branch from 7709d56 to 47e3f9b Compare April 7, 2026 08:16
@waveywaves waveywaves marked this pull request as ready for review April 7, 2026 08:16
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="install.sh">

<violation number="1" location="install.sh:58">
P2: `validate_checksums_file` changes CWD with `cd "$1"` and never restores it. The script later runs `rm -r ${TMP_DIR}` while still inside TMP_DIR, which fails and causes the script to exit under `set -e`, leaving the temp directory behind.</violation>

<violation number="2" location="install.sh:85">
P2: `--help` prints usage but does not exit, so the installer proceeds with downloads and installation instead of stopping.</violation>

<violation number="3" location="install.sh:92">
P2: `--path` does not validate a following argument, so with `set -u` the script exits on an unbound `$1` when `--path` is the final CLI argument.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Add install.sh to the main repository (previously only in the now-archived
chainloop-dev/docs repo) with the following improvements:

1. Add early validation after argument parsing to verify the --path
   installation directory exists before downloading anything. Provides a
   clear error message with a suggested fix (mkdir -p) instead of failing
   silently or showing confusing sudo errors.

2. Improve the install step to provide proper error output when the binary
   installation fails, instead of silently redirecting stderr to /dev/null.

Fixes chainloop-dev#2977

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
@waveywaves waveywaves force-pushed the fix/install-path-error-output branch from 47e3f9b to d8b747e Compare April 8, 2026 10:20
@waveywaves
Copy link
Copy Markdown
Contributor Author

@jiparis This PR is ready for review — all commits GPG-signed, DCO signed-off, rebased on latest main. Fixes the install script error when the target directory doesn't exist (issue #2580).

Use ( ) instead of { } for the function body so the cd only affects
the subshell. Prevents the rm -r ${TMP_DIR} cleanup from failing
when it runs while still inside TMP_DIR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="install.sh">

<violation number="1" location="install.sh:57">
P2: Changing checksum validation to a subshell breaks cwd side effects and causes signature download to write into caller CWD instead of TMP_DIR.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.


# checksums.txt file validation
# example: check_sha256 "${TMP_DIR}" checksums.txt
validate_checksums_file() (
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Changing checksum validation to a subshell breaks cwd side effects and causes signature download to write into caller CWD instead of TMP_DIR.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At install.sh, line 57:

<comment>Changing checksum validation to a subshell breaks cwd side effects and causes signature download to write into caller CWD instead of TMP_DIR.</comment>

<file context>
@@ -54,7 +54,7 @@ is_command() {
 # checksums.txt file validation
 # example: check_sha256 "${TMP_DIR}" checksums.txt
-validate_checksums_file() {
+validate_checksums_file() (
   cd "$1"
   if is_command sha256sum; then
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When provided path to install script does not exist doesn't provide error output

1 participant