Skip to content

fix(install): install without pipx on Ubuntu 24.04 and Debian 12 through a private venv (OSS-69) - #55

Merged
adityamishra-hydradb merged 13 commits into
mainfrom
adityamishra/oss-69-installer
Dec 4, 2026
Merged

adityamishra-hydradb merged 13 commits into
mainfrom
adityamishra/oss-69-installer

Conversation

@adityamishra-hydradb

@adityamishra-hydradb adityamishra-hydradb commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

For humans

The problem (Linear OSS-69). curl -fsSL https://cli.hydradb.com/install | bash fails on Ubuntu 24.04 and Debian 12 when pipx is not installed. The installer falls back to pip install --user, and these distros refuse it (PEP 668, externally-managed-environment), so it exits 1. Tested in clean containers: the live installer fails 4 of 12 scenarios.

The fix. The installer now tries, in order:

  1. pipx, if it is installed.
  2. A private virtual environment at ~/.local/share/hydradb-cli/venv, linked into ~/.local/bin/hydradb. No sudo needed, and it never touches the system Python.
  3. pip install --user, only where Python allows it.
  4. Otherwise it stops with clear help for the platform: sudo apt install python3-venv (or pipx) on Debian/Ubuntu, Homebrew on macOS, dnf on Fedora.

Safety rules (from 2 rounds of adversarial review):

  • It never changes or deletes a hydradb or a directory it did not make, unless HYDRADB_CLI_FORCE=1. A marker file identifies its own venv.
  • It checks that the installed hydradb --version matches the version it installed.
  • It never edits shell profiles; it prints the PATH line instead.
  • It stops when run as root, unless HYDRADB_CLI_ALLOW_ROOT=1 is set (for Dockerfiles and CI). This is a behaviour change; see the CHANGELOG.
  • The whole script runs from main on its last line, so a cut-off download does nothing.
  • Pins accept an optional v (HYDRADB_CLI_VERSION=v0.2.0). Network errors say "network error", not "no wheel found".

Docs. README: the install order, macOS (Homebrew Python, zsh PATH), Linux PATH, pinning (curl ... | HYDRADB_CLI_VERSION=0.2.0 bash; the old form HYDRADB_CLI_VERSION=x curl ... | bash was silently ignored), root and Dockerfiles, and an uninstall that removes only what the installer made. The docs.hydradb.com page is a separate mintlify PR and must merge together with this one.

Tests. tests/install/ runs install.sh in clean containers (make test-install, and .github/workflows/install.yml on PRs plus a weekly run). The result is 25 of 25 scenarios and 154 checks green. They cover Ubuntu 22.04/24.04, Debian 12, Fedora and python:3.12-slim, with and without pip, pipx and venv, plus root, bash 3.2 (macOS), broken venvs, unrelated files, pip user = true, upgrades, pins and offline runs. Every new scenario fails on the old script and passes now. shellcheck -S style is clean.

After merge: the live cli.hydradb.com/install serves this script from main (GitHub Pages). The 0.2.3 release (hydradb-cli PR 54) then makes it install 0.2.3. README.md will conflict with PR 54; whichever merges second needs a merge from main.

For agents

  • Linear OSS-69. The design decision and the repro matrix are in the OSS-69 report; the review rounds are in oss69-review-r1-.md and oss69-review-r2-.md.
  • Not in this PR: a concurrency lock (decided no), wheel checksum/attestation (later), and https_enforced on GitHub Pages (a repo admin setting).
  • The CHANGELOG has an older ## Unreleased section below 0.2.2 that was already on main; tidy it at the next release.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

adityamishra-hydradb and others added 10 commits December 2, 2026 18:24
tests/install/run.sh runs the installer as a normal user in Ubuntu 24.04,
Ubuntu 22.04, Debian 12, Fedora and python:3.12-slim images, with and
without pipx, python3-venv and pip. Each scenario checks that
`hydradb --version` works after a fresh install, a re-run, a forced
re-run, a pinned older version and an upgrade back to the latest
release. A system with only python3 must fail with install help.

The Installer workflow runs every scenario on changes to the installer
and once a week. `make test-install` runs them locally.

On main, u24-pip and d12-pip fail with PEP 668
(externally-managed-environment), and u24-pyonly fails without help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
On Debian 12 and Ubuntu 24.04 without pipx, the installer ran
`pip install --user`, which pip refuses there (PEP 668). The install
failed with externally-managed-environment.

Without pipx, the installer now makes a virtual environment in
~/.local/share/hydradb-cli/venv and links ~/.local/bin/hydradb to it.
When python3-venv is missing, it makes the venv with --without-pip and
fills it with the system pip (--python, pip 22.3 or later).
`pip install --user` is used only when Python allows it. When no method
works, the installer stops and tells the user to install pipx.

Other changes:
- A re-run keeps the method of the existing install (pipx, venv or
  pip --user), so it upgrades in place.
- An existing ~/.local/bin/hydradb that the installer did not make is
  not replaced unless HYDRADB_CLI_FORCE=1.
- A venv made by a failed run is removed.
- The script runs from main(), so a partial download does nothing.
- It no longer upgrades the user's own pip.
- The default repository is hydra-db/hydradb-cli.
- It runs `hydradb --version` and fails if that fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
…g (OSS-69)

- The README lists the three install methods in the order the installer
  tries them, and how a re-run behaves.
- Pinning and forcing put the variable on bash, not on curl.
  `HYDRADB_CLI_VERSION=0.1.1 curl ... | bash` sets the variable only for
  curl, so the installer ignored it and installed the latest release.
- The version examples use 0.2.0, which has a release. 0.2.1 has none.
- Links use hydra-db/hydradb-cli.
- The release-wheel example uses pipx, because `pip install` of a URL is
  refused on Debian 12 and Ubuntu 24.04 too.
- New Uninstall section. The prerequisites no longer tell users to
  upgrade the system pip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
When the system Python is upgraded, the venv's bin/python can point to
nothing. The next run then made a new venv on top of the old one. It now
passes --clear, so the old files go first.

Found in self-review; checked by deleting bin/python in a container and
running the installer again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
- Find an existing venv by its directory and marker, not by a working
  bin/python, so a broken venv is rebuilt and pipx is not chosen. Remove
  our own broken link before pipx or pip --user write theirs.
- Check the command that this run installed (the venv link, the pipx
  link, the pip --user script), and compare its --version output with the
  version that was installed. A mismatch is an error.
- The PATH hint names only ~/.local/bin, the pipx bin dir or the pip
  user bin dir, never the venv bin dir.
- pip --user does not write over an unrelated hydradb without
  HYDRADB_CLI_FORCE=1.
- Stop when run as root, unless HYDRADB_CLI_ALLOW_ROOT=1.
- Read XDG_DATA_HOME once; compare the link by real path and skip ln
  when it is already right; on a failed link remove the new venv and
  give a clean error.
- Validate HYDRADB_CLI_VERSION (a leading v is removed) and print the
  repo and wheel URL.
- No pipe into grep -q; add python3.14; no colour when not a terminal;
  show the venv pip output only when pip fails.
- Help text per system: python3-venv or pipx on Debian/Ubuntu,
  brew on macOS, and how to get Python 3.10+.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
…SS-69)

slim-upgrade made its old install with https://cli.hydradb.com/install.
After this branch merges, that URL serves the new installer, so the test
would fail for good. It now makes the old pip --user install directly
from the 0.1.1 wheel, as the old installer did.

New scenarios: broken venv then pipx (u24-venv-pipx), unrelated hydradb
with the venv (u24-venv-other), with pipx (u24-pipx-other) and with
pip --user (u22-pip-other), root with HYDRADB_CLI_ALLOW_ROOT=1
(slim-root), root without it (slim-root-refuse), and bash 3.2
(bash32). Every full scenario also pins with a leading v. The Installer
job gets a 20-minute timeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
… (OSS-69)

- Describe the order pipx, private venv, pip --user where allowed, stop
  with help, and what each method needs.
- A stock Ubuntu 24.04 or Debian 12 desktop needs python3-venv or pipx
  first; say so.
- Add macOS (Apple python3 is 3.9; brew, zsh PATH), Linux bash PATH, the
  pin with or without a leading v, and do not use sudo
  (HYDRADB_CLI_ALLOW_ROOT=1 for containers).
- Uninstall removes only what the installer made: the venv link only if
  it points into the venv; pip --user with the same Python; ~/.hydradb.
- Say where the method is printed, not "the last line".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
- pipx: check the pipx bin dir before pipx runs. A file that pipx did not
  make stops the install, also on a re-run, unless HYDRADB_CLI_FORCE=1.
- venv: only a directory with our marker is ours. A non-empty directory
  without it stops the install and is not changed. --clear runs only on
  a venv of ours, and a failed run removes only a directory that did not
  exist before it.
- venv: run pip with PIP_USER=0, so pip.conf `user = true` or an
  exported PIP_USER=1 does not break the install.
- Root: use EUID, not id. The refusal shows where the flag goes, and
  talks about sudo only when SUDO_USER is set. A root install that is
  not on PATH gets an ENV PATH hint for a Dockerfile.
- An old pip --user script of hydradb-cli is named as such, with the
  exact uninstall command.
- Try GitHub 3 times, and report a network error as a network error,
  not as "No wheel found".
- Remove a marker that no venv is left for after a switch to pipx or
  pip --user.
- Say what to do when the installed CLI reports another version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
New scenarios: u24-venv-userdir, u24-venv-homevenv, u24-venv-pipuser,
u24-venv-pipconf, u24-venv-oldpip, u24-offline (docker --network none).
u24-pipx-other runs the installer twice and then with FORCE.
u24-venv-pipx checks that pipx runs before "no second copy", and that a
switch to pipx leaves no marker. slim-root checks the Dockerfile PATH
hint. slim-root-refuse checks the container, sudo and no-id messages.
bash32 checks that the shell under test is bash 3.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
…SS-69)

- Show where HYDRADB_CLI_ALLOW_ROOT goes, with a Dockerfile example
  that also sets ENV PATH.
- Uninstall: label the blocks pipx, venv and pip-user as the installer
  prints them; remove the installer's directory (venv and marker) for
  every method; cover XDG_DATA_HOME and HYDRADB_CLI_BIN_DIR; name the
  pip cache and pipx shared files as optional cleanup.
- Pin example uses 0.2.0, the version the README documents.
- CHANGELOG: root runs of the curl installer now need the flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

@hydra-mira-review review

@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

/devin review

@hydra-mira-review

hydra-mira-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Mira score 5/5 · 🟢 Good to merge

  • No findings in the code.
  • Ship with or after: Publish the companion installation documentation.
  • Confirm outside this PR: Publish the updated installer through GitHub Pages, Root-running installation consumers must opt in.
  • Finish the requirement: Never change unrelated commands or directories without explicit force.
1 more
  • Read these high-risk changes closely: Check ownership before replacing commands or directories, Supporting changes.

Users on newer Ubuntu and Debian systems gain an installation path that avoids system Python restrictions. The installer adds a private virtual environment fallback, ownership checks, version verification, and root restrictions. Documentation and container tests cover the installation paths and behavior changes.

Before this ships · 1 with another PR, 2 to confirm, 2 in place
  • ⏳ Publish the companion installation documentation (order), needed in docs.hydradb.com Mintlify repository. The PR description identifies a companion Mintlify PR and requires it to merge together with this installer. Coordinate publication of that PR with the installer deployment.
  • ❔ Publish the updated installer through GitHub Pages (infra), needed in GitHub Pages for cli.hydradb.com. CNAME declares cli.hydradb.com; the Pages source configuration is not established. Confirm Pages publishes the root install file from main when this PR merges.
  • ❔ Root-running installation consumers must opt in (config), needed in External Dockerfiles and CI jobs using the hosted installer. The installer now rejects root by default; updates to external consumers are not established. Set HYDRADB_CLI_ALLOW_ROOT=1 for Bash in intended root installations before the updated script becomes live.
  • ✅ Release wheels matching the installer's filename convention (contract), needed in hydra-db/hydradb-cli release publishing. .github/workflows/publish.yml checks the tag-derived wheel filename and uploads matching artifacts to the release.
  • ✅ Version output matching the installed package version (contract), needed in HydraDB CLI executable. src/hydradb_cli/main.py prints the package version as a separate token through its version callback.
How this PR works · 7 changes, 2 high risk, 5 medium risk

The curl installer fails on Ubuntu 24.04 and Debian 12 without pipx because Python rejects its pip user installation. This PR adds a private virtual environment before that fallback and prints platform-specific help when prerequisites are missing. It also protects existing files, verifies the installed version, and requires explicit permission for root installations.

1. Require explicit permission for root installations · 🟠 medium risk · install +1

Root installations now stop unless explicitly allowed; previously they proceeded. Installation work moves into main, called last, and Python discovery adds Python 3.14.

Risk: Existing root-running build pipelines stop at installation until they explicitly allow root.

Check:

  • Check root refusal both with and without SUDO_USER.
  • Check an allowed root installation prints a Dockerfile PATH instruction.

In install:107-144, install:689-708, install:756 and 3 more.

2. Resolve release wheels with validated pins and network retries · 🟠 medium risk · install +1

Users can pin versions with or without a leading v, and connection failures receive separate diagnostics. The default release repository changes to hydra-db/hydradb-cli.

Risk: Users cannot install a release if repository selection, tag normalization, or wheel naming produces an incorrect URL.

Check:

  • Check 0.1.1 and v0.1.1 select the same wheel.
  • Check an offline pinned installation reports a connection problem rather than a missing wheel.

In install:32-35, install:147-271, install.sh:32-35 and 1 more.

3. Choose an eligible method and preserve existing installations · 🟠 medium risk · install +1

Fresh installations now prefer pipx, then a private venv, then an allowed pip user installation. Reruns prefer eligible existing installations; the user method stops upgrading pip itself.

Risk: Users receive an installation error or a second CLI copy if method detection chooses incorrectly.

Check:

  • Check Ubuntu 24.04 with pip but without ensurepip selects the private venv.
  • Check an existing pip user installation remains the upgrade target when Python permits it.

In install:274-344, install:575-605, install:710-726 and 3 more.

4. Check ownership before replacing commands or directories · 🔴 high risk · install +1

Existing commands now receive ownership checks before replacement, and nonempty unmarked venv directories are rejected. Venv command collisions are preserved with warnings unless force is enabled.

Risk: An incorrect ownership decision can overwrite an unrelated command or delete user files, which reverting the installer cannot restore.

Check:

  • Check unrelated files and links survive repeated installations without force.
  • Read the marker checks and cleanup paths against a user directory substituted at the venv location.

How it works:

  1. check_pipx_target validates the command before pipx runs; pipx directory discovery supports older pipx versions.
  2. link_command preserves conflicting commands and recognizes older pip scripts to print removal instructions.
  3. install_with_pip_user checks existing script contents before pip writes its command.
  4. install_with_venv rejects symlink directories and nonempty unmarked directories; remove_new_venv cleans directories created during the current run.

What it touches:

  • install.sh: install_with_pipx.
  • install.sh: install_with_pip_user.
  • install.sh: install_with_venv.
  • HYDRADB_CLI_FORCE.
  • HYDRADB_CLI_HOME.
  • HYDRADB_CLI_BIN_DIR.
  • PIPX_BIN_DIR and PIPX_HOME.
  • Ownership markers and resolved link targets determine which local installation files may be replaced or removed.

In install:350-475, install:484-497, install:563-573 and 3 more.

5. Create and repair a private virtual environment · 🟠 medium risk · install +1

Users without pipx can now install into a private venv linked from their bin directory. Marked environments with broken Python are rebuilt before installation.

Risk: Users lose access to the CLI if environment creation, repair, dependency installation, or command linking fails.

Check:

  • Check installation with user = true in pip configuration.
  • Check a broken marked venv is rebuilt and a pip-less venv can acquire pip through ensurepip.

In install:38-52, install:478-561, install:740-746 and 3 more.

6. Verify the installed executable and explain PATH conflicts · 🟠 medium risk · install +1

Installation success now requires the newly installed executable to report the requested version. Previously, the installer could run another PATH copy and ignore version-command failure.

Risk: Users receive false success or an unnecessary installation failure if executable selection or version matching is wrong.

Check:

  • Check a different hydradb earlier on PATH triggers a warning while the newly installed executable is verified.
  • Check mismatched version output returns failure.

In install:607-687, install:728-752, install.sh:607-687 and 1 more.

7. Supporting changes · 🔴 high risk · README.md +6

Installation recipes now explain prerequisites, root opt-in, correct pinning, PATH setup, and guarded uninstall commands. Docker checks cover installation and repair; CI checks both installer copies.

Risk: Incorrect recipes can remove local files, while incomplete checks can let installation regressions merge unnoticed.

Check:

  • Check the uninstall recipe preserves neighboring files and CLI configuration.
  • Check the workflow's installer comparison and scenario matrix remain aligned with the local runner.

What it touches:

  • Makefile: test-install.
  • .github/workflows/install.yml: containers.
  • make test-install.
  • Pull requests and pushes affecting installer paths.
  • Weekly and manual GitHub Actions runs.
  • Documented uninstall commands remove the matching venv link and marked environment while retaining CLI configuration and shared caches.

In README.md:36-187, CHANGELOG.md:3-7, Makefile:31-34 and 4 more.

Questions for the author:

  • Which companion Mintlify PR must merge with this change, and is it ready to publish the new root and prerequisite instructions?
Requirement check · 10 met, 1 partly met, 2 for another PR · from the PR description
  • ✅ Install without pipx on Ubuntu 24.04 and Debian 12 without writing to system Python (met). can_make_venv accepts ensurepip or pip 22.3 or newer; install_with_venv installs privately and otherwise prints prerequisite help.
  • ✅ Prefer pipx, then a private venv, then pip user installation where allowed (met). main applies this order for fresh installations and checks externally_managed before selecting the user method.
  • ✅ Retain the existing installation method on reruns (met). main prioritizes existing pipx packages, usable or repairable marked venvs, and permitted pip user installations.
  • 🟡 Never change unrelated commands or directories without explicit force (partial). Command replacement is guarded, but install_with_venv also accepts a preexisting empty directory without a marker or force.
  • ✅ Verify that the installed command reports the version just installed (met). verify_install runs the selected executable and requires the expected version in successful output.
  • ✅ Print PATH instructions without editing shell profiles (met). report prints shell and Dockerfile instructions and warns about commands earlier on PATH.
  • ✅ Refuse root unless explicitly allowed and document the compatibility change (met). refuse_root checks HYDRADB_CLI_ALLOW_ROOT; CHANGELOG.md and README.md describe the required opt-in.
  • ✅ Start installation only after the complete script has been received (met). Both installer files define installation functions before the final main "$@" invocation.
  • ✅ Accept optional leading v in pins and distinguish connection errors from missing wheels (met). check_pinned_version normalizes pins; asset_exists gives HTTP 404 a separate result from connection failures.
  • ✅ Document platform prerequisites, pinning, root installations, PATH setup, and guarded uninstall (met). README.md adds these recipes, including assigning environment variables to Bash rather than curl.
  • ✅ Add container scenarios and automated installer checks (met). tests/install/run.sh defines distro and failure scenarios; the installer workflow adds comparison, shellcheck, and scheduled container jobs.
  • ➖ Update the hosted installation documentation alongside this change (for another PR). The PR description assigns the docs.hydradb.com page to a companion Mintlify PR.
  • ➖ Make unpinned installations select version 0.2.3 after its release (for another PR). The PR description assigns publication of 0.2.3 to hydra-db/hydradb-cli PR ci+docs: publish 0.2.3 to PyPI with the org token, and fix README examples that fail on 0.2.3 (OSS-71) #54; this installer follows the latest published release.
Diagram of the changed files
graph LR
  workflow[".github/workflows/install.yml"] --> tests["tests/install/run.sh"]
  make["Makefile"] --> tests
  tests --> installer["install.sh"]
Loading

Comment @hydra-mira-review help for commands.

hydra-mira-review[bot]

This comment was marked as resolved.

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

adityamishra-hydradb and others added 3 commits December 3, 2026 01:35
- The ownership marker is now inside the venv. A marker beside it could
  outlive the venv and let --clear wipe a directory that the user put at
  the same path. A venv path that is a link is refused.
- is_pipx_link accepts only a link into pipx's venv of this package. When
  pipx cannot print its paths (pipx 1.0.0), PIPX_BIN_DIR / PIPX_HOME and
  their defaults are used; if ownership still cannot be shown, the file
  is replaced only with HYDRADB_CLI_FORCE=1. The final pipx check uses it.
- Native Windows Python keeps the pip --user method (venv paths differ).
- A venv with no pip gets one from ensurepip when that is there now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
- u24-venv-replaced: a replaced venv dir and a venv link are not touched;
  the documented uninstall keeps other files.
- u24-venv-nopip: upgrade a venv with no pip after system pip is gone.
- u22-pipx-link: custom PIPX_BIN_DIR on pipx 1.0.0, and an unrelated link
  is not replaced without HYDRADB_CLI_FORCE=1.
- run.sh returns a failed image build instead of running an old image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
The venv uninstall deletes the venv only when the marker is in it and
rmdirs the parent only when empty; pipx and pip-user have no step for
that directory. The Dockerfile line runs with pipefail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

@hydra-mira-review review

@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

@adityamishra-hydradb
adityamishra-hydradb merged commit 5b1e170 into main Dec 4, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants