Skip to content

install.sh fails in non-interactive environments (Docker builds, CI) #149

@stephenleo

Description

@stephenleo

Problem

The install script fails with exit code 1 when run inside a Docker RUN step (or any non-interactive CI environment) because it calls read -r answer </dev/tty for two interactive prompts:

  1. libsecret-tools prompt — shown when secret-tool is not found on Linux
  2. Starship prompt — shown when starship is not found

Docker BuildKit build steps have no controlling terminal, so opening /dev/tty returns No such device or address. Because the script uses set -euo pipefail, this kills the entire build.

Observed error (from VS Code Dev Containers log):

ERROR: failed to solve: process "/bin/sh -c curl -fsSL https://cship.dev/install.sh | bash" did not complete successfully: exit code: 1

Reproduction

FROM ubuntu:24.04
RUN curl -fsSL https://cship.dev/install.sh | bash
docker build .
# → exit code: 1

Suggested Fix

Guard each interactive prompt with a TTY check before attempting to read from /dev/tty:

if [ "$OS" = "Linux" ] && ! command -v secret-tool >/dev/null 2>&1; then
  if { exec 3</dev/tty; } 2>/dev/null; then
    exec 3<&-
    printf "Install libsecret-tools? (required for usage limits on Linux) [Y/n] "
    read -r answer </dev/tty
    case "$answer" in
      [Nn]*) echo "Skipping — usage limits module unavailable until installed manually." ;;
      *)     sudo apt-get install -y libsecret-tools ;;
    esac
  else
    echo "Non-interactive mode: skipping libsecret-tools (install manually if needed)."
  fi
fi

Same pattern for the Starship prompt. Alternatively, honour a CSHIP_NONINTERACTIVE=1 env var or check the common CI variable to auto-select defaults silently.

Workaround

Pre-install the dependencies before running the cship installer so the prompts are never reached:

RUN apt-get update && apt-get install -y libsecret-tools
RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes
RUN curl -fsSL https://cship.dev/install.sh | bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions