Skip to content

Commit e2d0dbc

Browse files
konardclaude
andcommitted
Fix Rocq/Opam installation for non-root user context
The opam install script was receiving "y" as installation path instead of accepting the default. Fix by providing the correct path ($HOME/.local/bin) as first input. Also add fallback direct binary download and ensure .opam directory always exists for COPY --from. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c8e0316 commit e2d0dbc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

ubuntu/24.04/rocq/install.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,21 @@ log_step "Installing Rocq/Coq via Opam"
2525
if ! command_exists opam; then
2626
log_info "Installing Opam (OCaml package manager)..."
2727

28-
bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh) --no-backup" <<< "y" || {
29-
maybe_sudo apt install -y opam || true
28+
# Install opam binary to user-writable location
29+
OPAM_BIN_DIR="$HOME/.local/bin"
30+
mkdir -p "$OPAM_BIN_DIR"
31+
export PATH="$OPAM_BIN_DIR:$PATH"
32+
# The install script asks: 1) path [/usr/local/bin], 2) create dir? [Y/n]
33+
printf '%s\n%s\n' "$OPAM_BIN_DIR" "Y" | bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh) --no-backup" || {
34+
# Fallback: download opam binary directly
35+
ARCH="$(uname -m)"
36+
case "$ARCH" in
37+
x86_64) OPAM_ARCH="x86_64" ;;
38+
aarch64) OPAM_ARCH="arm64" ;;
39+
*) OPAM_ARCH="$ARCH" ;;
40+
esac
41+
curl -fsSL "https://github.com/ocaml/opam/releases/latest/download/opam-2.3.0-${OPAM_ARCH}-linux" -o "$OPAM_BIN_DIR/opam" && \
42+
chmod +x "$OPAM_BIN_DIR/opam" || true
3043
}
3144

3245
if command_exists opam; then
@@ -82,4 +95,10 @@ if command_exists opam; then
8295
fi
8396
fi
8497

98+
# Ensure .opam directory exists (required for COPY --from in full-sandbox)
99+
if [ ! -d "$HOME/.opam" ]; then
100+
log_warning "Opam directory not found - creating minimal structure"
101+
mkdir -p "$HOME/.opam"
102+
fi
103+
85104
log_success "Rocq/Coq installation complete"

0 commit comments

Comments
 (0)