Skip to content

Commit 0e05375

Browse files
CopilotClayMav
andcommitted
Change default install directory to ~/.local/bin for non-sudo installs
- Default INSTALL_DIR changed from /usr/local/bin to $HOME/.local/bin - Install logic creates directory without sudo first, falls back to sudo only when needed - Directory created with explicit 0755 permissions - Updated help text and README to reflect new default Co-authored-by: ClayMav <16675291+ClayMav@users.noreply.github.com> Agent-Logs-Url: https://github.com/wherobots/wbc-cli/sessions/511781f7-0451-4138-890c-004bea303067
1 parent d975c7c commit 0e05375

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ If you have access to `wherobots/wbc-cli`, use the installer script:
137137
Notes:
138138
- Requires `gh` CLI and `gh auth login` with repo access.
139139
- Defaults to release tag `latest-prerelease`.
140-
- Installs to `/usr/local/bin/wherobots` (override with `--install-dir`).
140+
- Installs to `~/.local/bin/wherobots` (override with `--install-dir`).
141141
- Verifies SHA-256 checksum by default.
142142

143143
## Build and release

scripts/install-release.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
REPO="${WHEROBOTS_CLI_REPO:-wherobots/wbc-cli}"
55
TAG="${WHEROBOTS_CLI_TAG:-latest-prerelease}"
66
BINARY_NAME="${WHEROBOTS_CLI_BINARY:-wherobots}"
7-
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
7+
INSTALL_DIR="${INSTALL_DIR:-${HOME}/.local/bin}"
88
SKIP_CHECKSUM=0
99

1010
usage() {
@@ -20,7 +20,7 @@ Usage:
2020
Options:
2121
--repo <owner/name> GitHub repository (default: wherobots/wbc-cli)
2222
--tag <tag> Release tag (default: latest-prerelease)
23-
--install-dir <path> Install directory (default: /usr/local/bin)
23+
--install-dir <path> Install directory (default: ~/.local/bin)
2424
--binary-name <name> Binary name/asset prefix (default: wherobots)
2525
--skip-checksum Skip checksum verification
2626
-h, --help Show help
@@ -136,15 +136,26 @@ if [[ "$SKIP_CHECKSUM" -eq 0 ]]; then
136136
fi
137137

138138
TARGET="${INSTALL_DIR}/${BINARY_NAME}"
139-
if [[ -d "$INSTALL_DIR" && -w "$INSTALL_DIR" ]]; then
139+
140+
# Ensure the install directory exists; create without sudo when possible.
141+
if [[ ! -d "$INSTALL_DIR" ]]; then
142+
if ! mkdir -m 0755 -p "$INSTALL_DIR" 2>/dev/null; then
143+
if command -v sudo >/dev/null 2>&1; then
144+
sudo mkdir -p "$INSTALL_DIR"
145+
else
146+
echo "Cannot create $INSTALL_DIR and sudo is unavailable." >&2
147+
exit 1
148+
fi
149+
fi
150+
fi
151+
152+
if [[ -w "$INSTALL_DIR" ]]; then
140153
install -m 0755 "$TMP_DIR/$ASSET" "$TARGET"
141154
else
142155
if command -v sudo >/dev/null 2>&1; then
143-
sudo mkdir -p "$INSTALL_DIR"
144156
sudo install -m 0755 "$TMP_DIR/$ASSET" "$TARGET"
145157
else
146158
echo "No write access to $INSTALL_DIR and sudo is unavailable." >&2
147-
echo "Try: --install-dir \"$HOME/.local/bin\"" >&2
148159
exit 1
149160
fi
150161
fi

0 commit comments

Comments
 (0)