Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ set -e
# As that user it installs bench itself, needing no privileges at all.

# ── configuration ─────────────────────────────────────────────────────────────
# All three point at the same GitHub repo; override PILOT_GITHUB_SLUG to install
# from a fork (releases + self-reference URL follow it).
# All three point at the same GitHub repo/branch; override PILOT_GITHUB_SLUG and
# PILOT_BRANCH to install from a fork (releases + self-reference URL follow both).
GITHUB_SLUG="${PILOT_GITHUB_SLUG:-frappe/pilot}"
INSTALL_URL="https://raw.githubusercontent.com/$GITHUB_SLUG/develop/install.sh"
REPO_URL="${PILOT_REPO_URL:-https://github.com/$GITHUB_SLUG}"
BRANCH_NAME="${PILOT_BRANCH:-develop}"
INSTALL_URL="https://raw.githubusercontent.com/$GITHUB_SLUG/$BRANCH_NAME/install.sh"
PILOT_DIR="$HOME/pilot"
BENCH_USER="${BENCH_USER:-frappe}"
# Lets an unattended run answer sudo, which `curl | sh` cannot prompt for.
Expand Down Expand Up @@ -73,6 +73,18 @@ is_root() {
[ "$(id -u)" -eq 0 ]
}

# `su -` and a fresh sudo session both start a clean environment, so a fork or
# branch override given to this invocation would otherwise be lost across the
# root -> bench-user handoff. Only print vars that differ from the defaults,
# so the common case still shows a plain, copy-pasteable command.
non_default_env() {
out=""
[ "$GITHUB_SLUG" = "frappe/pilot" ] || out="$out PILOT_GITHUB_SLUG=$GITHUB_SLUG"
[ "$BRANCH_NAME" = "develop" ] || out="$out PILOT_BRANCH=$BRANCH_NAME"
[ -z "$DEV_MODE" ] || out="$out PILOT_DEV=1"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 P2 — Re-Run Command Loses DEV_MODE And PILOT_REPO_URL

non_default_env emits PILOT_GITHUB_SLUG but not PILOT_REPO_URL, and does not reliably forward DEV_MODE when it is set as a shell variable rather than an exported env var. When a user sets PILOT_REPO_URL to point at a local file path or alternate host (as the smoke tests do), the printed re-run command omits it and the second invocation clones from the default GitHub URL instead of the intended repository. Similarly, DEV_MODE set via --dev flag parsing may not be exported, so su - $BENCH_USER and wget ... | sh re-run commands will not carry it.

Give this to a coding agent
Fix this in the repository. Change nothing else.

install.sh:84
install.sh:489
[P2 bug] Re-Run Command Loses DEV_MODE And PILOT_REPO_URL
non_default_env emits PILOT_GITHUB_SLUG but not PILOT_REPO_URL, and does not reliably
forward DEV_MODE when it is set as a shell variable rather than an exported env var.
When a user sets PILOT_REPO_URL to point at a local file path or alternate host (as the
smoke tests do), the printed re-run command omits it and the second invocation clones
from the default GitHub URL instead of the intended repository. Similarly, DEV_MODE set
via `--dev` flag parsing may not be exported, so `su - $BENCH_USER` and `wget ... | sh`
re-run commands will not carry it.

bug · confidence 75% · reply to this comment if it is wrong and I will remember

printf '%s' "$out"
}

# Piping this script through `curl | sh` leaves stdin occupied, so sudo's own
# prompt cannot read an answer. Ask via /dev/tty and cache it instead.
run_sudo() {
Expand Down Expand Up @@ -275,7 +287,7 @@ install_system_packages() {
echo "sudo is not installed and you are not root, so base packages cannot"
echo "be installed. Re-run this installer as root first, then as the bench user:"
echo ""
echo " wget -qO- $INSTALL_URL | sh # as root"
echo " wget -qO- $INSTALL_URL |$(non_default_env) sh # as root"
exit 1
fi
fi
Expand Down Expand Up @@ -474,7 +486,7 @@ prepare_host() {
echo " the installer again:"
echo ""
echo " su - $BENCH_USER"
echo " curl -fsSL $INSTALL_URL | bash"
echo " curl -fsSL $INSTALL_URL |$(non_default_env) bash"
echo "========================================================================"
}

Expand Down Expand Up @@ -502,6 +514,16 @@ require_linger() {
fetch_pilot() {
if [ -n "$DEV_MODE" ]; then
if [ -d "$PILOT_DIR/.git" ]; then
current_url="$(git -C "$PILOT_DIR" remote get-url origin 2>/dev/null || true)"
current_branch="$(git -C "$PILOT_DIR" rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
if [ "$current_url" != "$REPO_URL" ] || [ "$current_branch" != "$BRANCH_NAME" ]; then
echo "$PILOT_DIR already tracks $current_url ($current_branch), not $REPO_URL ($BRANCH_NAME)." >&2
echo "Remove it and re-run to switch forks or branches (a --dev checkout may hold" >&2
echo "local edits, so this is not done automatically):" >&2
echo "" >&2
echo " rm -rf $PILOT_DIR" >&2
exit 1
fi
echo "Updating pilot (dev)..."
git -C "$PILOT_DIR" pull
else
Expand Down
Loading