pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Support dotfiles workflow: respect symlink location for environment paths

Open claydugo opened this issue 1 month ago • 2 comments

Problem

When pixi.toml is a symlink, pixi resolves it to the real file location and creates the .pixi/ directory relative to the target, not the symlink. This breaks common dotfiles management workflows where users symlink config files from a git repository to their home directory.

Minimal Reproduction

Setup:

# Create a dotfiles repo with pixi.toml
mkdir -p ~/dotfiles
cat > ~/dotfiles/pixi.toml << 'EOF'
[workspace]
name = "shell_env"
channels = ["conda-forge"]
platforms = ["linux-64"]

[dependencies]
python = "3.13.*"
ripgrep = "*"
EOF

# Symlink it to home directory
ln -s ~/dotfiles/pixi.toml ~/pixi.toml

# Auto-activate in bashrc
echo 'eval "$(pixi shell-hook 2>/dev/null)"' >> ~/.bashrc

Current behavior:

$ source ~/.bashrc
$ echo $CONDA_PREFIX
/home/user/dotfiles/.pixi/envs/default  # Points to dotfiles repo

Expected behavior:

$ source ~/.bashrc
$ echo $CONDA_PREFIX
/home/user/.pixi/envs/default  # Environment in home directory

Why This Matters

Version controlling and syncing across machines

Current Workaround Issues

Users must either:

  • Option 1: Keep pixi.toml as a real file + manually sync it to the dotfiles repo
  • Option 2: Accept that the environment lives in ~/dotfiles/.pixi/envs/default (breaks tools that expect ~/.pixi/envs/default, harder to clean up)

Root Cause (AI assisted)

I used an AI tool to find this line, apologies if there is more nuance than this

The issue is in pixi_manifest/src/manifests/provenance.rs:65: Line/tag pinned view

pub fn absolute_path(&self) -> PathBuf {
    dunce::canonicalize(self.path.clone()).unwrap_or(self.path.to_path_buf())
}

dunce::canonicalize() always resolves symlinks to the real path, causing pixi to treat the dotfiles repo as the workspace root.

Additional Context

  • Platform: Linux (but affects all platforms)
  • Pixi version: 0.59.0
  • Workaround: See reproduction above - requires keeping files in sync manually

I am somewhat aware that this "global environment" isn't exactly the goal of this project but this is really the only issue I am hitting when trying to switch from standard conda to pixi with this workflow.

Would appreciate any thoughts on the best approach! Happy to contribute a PR if there's consensus on the solution.

claydugo avatar Nov 10 '25 15:11 claydugo

Yeah that root-cause seems problematic. I think we should then take the parent of the path, canonicalize that, and join it with the original filename.

Would you be able to make a PR?

baszalmstra avatar Nov 11 '25 15:11 baszalmstra

I do not have much Rust experience but made a pass at https://github.com/prefix-dev/pixi/pull/4912!

claydugo avatar Nov 11 '25 17:11 claydugo