Load binaries from a read-only lib dir

AS
15h ago
+187-4

On a read-only ABXPKG_LIB_DIR:

  • save_derived_cache skips the write.
  • EnvProvider returns the host binary instead of creating a new env/bin link.
  • write_cached_binary no longer creates missing provider roots.
  • Package-manager caches under $ABXPKG_LIB_DIR/cache/<provider> fall back to ABXPKG_TMP_CACHE_DIR.

It applies whenever the lib dir is on a read-only mount; there is no setting. Writable lib dirs are unchanged. The README documents the behaviour.

Tested:

  • uv run pytest tests/test_read_only_lib_dir.py: passes. It fails on main and with any one of the four changes removed. It installs into a Docker volume, makes a cached record stale, then mounts the volume read-only and loads, invalidates and reloads.
  • uv run pytest tests/test_envprovider.py tests/test_env_projection_concurrency.py tests/test_cache_timestamp_precision.py tests/test_central_lib_dir.py tests/test_uvprovider.py tests/test_binprovider.py: same results as main.
  • uv run prek run --files abxpkg/config.py abxpkg/base_types.py abxpkg/binprovider.py tests/test_read_only_lib_dir.py README.md: passes.
  • ArchiveBox 0.9.73 image with a read-only root: archivebox add failed with abxpkg could not resolve supervisord before and archives normally with this.

Refs ArchiveBox/ArchiveBox#1980


Summary by cubic

Fixes abxpkg failing to load installed binaries when ABXPKG_LIB_DIR is on a read-only mount, so container images with a read-only root filesystem keep resolving binaries instead of hitting EROFS.

  • On read-only mounts, derived.env writes are skipped (records are still re-validated on every read), provider roots aren't created, and EnvProvider returns the host binary without adding an env/bin link.
  • Package-manager caches under $ABXPKG_LIB_DIR/cache/<provider> fall back to the ABXPKG_TMP_CACHE_DIR location, as uv locks its cache even for read-only operations like pip show.
  • Detection is automatic via statvfs; writable lib dirs behave as before, and installing into a read-only lib dir still fails.
  • Adds a Docker integration test that installs into a volume, remounts it read-only, then loads, invalidates, and reloads binaries.