feat(install): support a custom INSTALL_DIR - #1574
Open
arlenvasconcelos wants to merge 2 commits into
Open
Conversation
The quick-install script hardcoded /usr/local/bin, which forces sudo on machines where the user has a perfectly good ~/.local/bin. INSTALL_DIR now overrides it, the directory is created when missing, and the success message names where the binary landed plus a note when that path is not on PATH. Relative paths are rejected up front: the script cds into the temp dir it extracts to and deletes, so a relative INSTALL_DIR would install into that dir and vanish. Covers both the custom-dir and rejected-relative-path cases in the installer workflow.
test -w is true for a writable regular file, so pointing INSTALL_DIR at a file took the no-sudo branch and failed late with "mv: cannot stat '<path>/': Not a directory" — after downloading the release. Checking for a non-directory alongside the absolute-path guard fails before any network work.
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.
Description
The quick-install script hardcoded
/usr/local/bin, which forces sudo on machines where the user has a perfectly good~/.local/bin.INSTALL_DIRnow overrides it, the directory is created when missing, and the success message names where the binary landed plus a note when that path is not onPATH.Relative paths are rejected up front: the script
cds into the temp dir it extracts to and then deletes, so a relativeINSTALL_DIRwould install into that dir and vanish.Default behaviour is unchanged — with no
INSTALL_DIRset, the install still goes to/usr/local/binand still escalates to sudo when that directory isn't writable.Files touched:
install.sh—INSTALL_DIRenv override, absolute-path guard,mkdir -p(via sudo when needed), install path in the success message,PATHmembership note.github/workflows/installers.yml— two smoke steps covering the new behaviourREADME.md— documents the custom install locationType of change
How has this been tested?
Installer-only change — it never touches a cluster, so the minikube/remote-cluster boxes don't apply.
sh -n install.sh— POSIX sh syntax check passes.The install block (
mkdir/-w/$SUDO/ PATH check) was exercised directly in a scratch directory: writable custom dir, missing custom dir that gets created, and a relativeINSTALL_DIR, which exits 1 before any download or extract.Two new CI steps in
installers.ymlrun the real script end to end on the ubuntu and macOS runners:INSTALL_DIR→ asserts bothkubectl-radar --versionandradar --versionfrom that directoryINSTALL_DIR→ asserts the install failsThe workflow's existing
shellcheck --shell=sh install.shstep is the lint gate for the new code; it was not run locally (shellcheck isn't installed on this machine).The existing default-path step (
sh ./install.sh→/usr/local/bin/kubectl-radar --version) is unchanged and still passes, which is the regression guard on the default.Tested locally with minikube/kind
Tested against a remote cluster
Added/updated unit tests
Checklist
Related issues
Fixes #1563
Note
Low Risk
Installer-only change with default behavior preserved; risk is limited to where binaries are placed on the user’s machine, with guards against relative paths and invalid targets.
Overview
The macOS/Linux quick-install script now accepts
INSTALL_DIRto override the default/usr/local/bin, so users can install into writable paths like~/.local/binwithout sudo. Relative paths are rejected before download/extract (they would land in the temp dir that gets deleted), and an existing non-directory path fails fast.Install flow creates the target directory when missing (
mkdir -p, with sudo when the dir isn’t writable), consolidates the binary move behind$SUDO, and improves post-install messaging: success names the install path and warns when that path isn’t onPATH.README documents the custom-location one-liner; CI adds smoke tests for a custom absolute
INSTALL_DIRand for a relative path that must fail without creating directories.Reviewed by Cursor Bugbot for commit 3e9fbce. Bugbot is set up for automated code reviews on this repo. Configure here.