Skip to content

feat: Add configuration options to control package link modes#5525

Merged
ruben-arts merged 10 commits intoprefix-dev:mainfrom
baszalmstra:claude/restrict-install-methods-ggRk8
May 6, 2026
Merged

feat: Add configuration options to control package link modes#5525
ruben-arts merged 10 commits intoprefix-dev:mainfrom
baszalmstra:claude/restrict-install-methods-ggRk8

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra commented Feb 18, 2026

Description

This PR adds three new configuration options to control which link modes are allowed during package installation:

  • allow-symbolic-links / PIXI_NO_SYMBOLIC_LINKS: Disallow symbolic links
  • allow-hard-links / PIXI_NO_HARD_LINKS: Disallow hard links
  • allow-ref-links / PIXI_NO_REF_LINKS: Disallow ref links (copy-on-write)

These options enable users to restrict package installation methods based on their environment requirements. The implementation includes:

  1. Configuration layer (pixi_config):

    • Added CLI flags (--no-symbolic-links, --no-hard-links, --no-ref-links) with corresponding environment variables
    • Added config file fields (allow_symbolic_links, allow_hard_links, allow_ref_links)
    • Proper serialization/deserialization and config merging
  2. Link mode derivation (pixi_install_pypi):

    • New derive_link_mode() function that implements a fallback chain:
      • Uses platform default if allowed
      • Falls back through Clone → Hardlink → Symlink → Copy based on restrictions
      • Copy is always available as a last resort
  3. Integration:

    • Wired through CommandDispatcher and CommandDispatcherBuilder
    • Applied to both conda package installation (via LinkOptions) and PyPI package installation
    • Propagated from workspace/global config to the installer

The configuration respects the standard precedence: CLI flags override config file settings, which override defaults.

Fixes #5332

How Has This Been Tested?

  • Existing snapshot tests updated to reflect new config fields
  • Configuration merging and CLI parsing covered by existing test infrastructure
  • Link mode derivation logic is straightforward and deterministic

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code Opus 4.6 Extended

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@baszalmstra baszalmstra changed the title Add configuration options to control package link modes feat: Add configuration options to control package link modes Feb 18, 2026
Copy link
Copy Markdown
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

The --no-ref-links is setup to work for pixi install but the config is not hooked up yet.

pixi config set allow-ref-links false doesn't work and as a fly by issue the config in a local to the project config file doesn't work at all. Maybe something your friend can do in a fly by fix?

@baszalmstra baszalmstra marked this pull request as draft February 20, 2026 14:40
@baszalmstra baszalmstra force-pushed the claude/restrict-install-methods-ggRk8 branch 2 times, most recently from 9c2860c to 18350d5 Compare May 1, 2026 12:52
claude and others added 9 commits May 1, 2026 19:45
Adds configuration options to control which installation methods (hardlinks,
reflinks, symlinks) are allowed during package installation. This is useful
for HPC environments like Lustre where reflinks consume excessive inodes.

Configuration options:
- `allow-symbolic-links`: Allow/disallow symbolic links (default: true)
- `allow-hard-links`: Allow/disallow hard links (default: true)
- `allow-ref-links`: Allow/disallow copy-on-write/reflinks (default: true)

These can be set in ~/.pixi/config.toml:
```toml
allow-ref-links = false
allow-hard-links = true
```

Or via CLI flags: `--no-ref-links`, `--no-hard-links`, `--no-symbolic-links`
Or via environment variables: `PIXI_NO_REF_LINKS`, `PIXI_NO_HARD_LINKS`, etc.

Implementation details:
- Conda: Integrated via rattler's LinkOptions passed to Installer
- PyPI: Integrated via uv's LinkMode with derive_link_mode() helper
- Config flows through CommandDispatcher to both installers

Closes prefix-dev#5332
Pass the user-configured link mode (derived from allow_symbolic_links,
allow_hard_links, allow_ref_links config) through to UvBuildDispatchParams
when building PyPI source distributions during dependency resolution.
This ensures the link mode restrictions are respected not just during
installation, but also when building wheels from source during the
solve phase.
The allow-symbolic-links, allow-hard-links, and allow-ref-links config
keys were registered in get_keys() and deserialized from TOML, but the
set() method was missing match arms for them — causing `pixi config set
allow-ref-links false` to fail with "Unknown key". Also add the keys to
partial_config() so `pixi config list` can display them individually.

https://claude.ai/code/session_014vnQN14HgHrid7ZrHjnWGD
Add test_config_allow_links that verifies:
- `pixi config set --local allow-ref-links false` works
- `pixi config list` shows the set values
- `pixi config list <key>` shows individual key values
- The local .pixi/config.toml file is written correctly
- `pixi config unset` removes a key
- Setting a value to true also works

Also add --no-ref-links, --no-hard-links, --no-symbolic-links CLI
flag tests to the existing test_cli_config_options test.

https://claude.ai/code/session_014vnQN14HgHrid7ZrHjnWGD
- Collapse derive_link_mode into a single allowance predicate plus an
  ordered fallback scan, dropping the redundant default-allowed branch
  and the narration comments.
- Drop the trivial Config::allow_symbolic_links/hard_links/ref_links
  accessors and read the public fields directly at call sites.
- Hoist the per-environment derive_link_mode call out of the PyPI solve
  loop in UpdateContext::update so it is computed once per workspace.
- Replace the if/else chains in From<ConfigCli> for Config with
  bool::then_some.
The --no-*-links flags need to appear on every command that exposes
ConfigCli; pixi publish was missed when the docs were last regenerated.
@baszalmstra baszalmstra force-pushed the claude/restrict-install-methods-ggRk8 branch from 18350d5 to 103b47a Compare May 1, 2026 19:59
@baszalmstra baszalmstra marked this pull request as ready for review May 6, 2026 08:15
@baszalmstra baszalmstra requested a review from ruben-arts May 6, 2026 08:16
@ruben-arts ruben-arts merged commit 9ec62a7 into prefix-dev:main May 6, 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.

Specify whether to reflink/hardlink from cache dir into environment

3 participants