Skip to content

Support dotfiles workflow: respect symlink location for environment paths #4907

@claydugo

Description

@claydugo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions