prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
3.15k stars 172 forks source link

Lock files / configuration for global environments #1280

Open kxmh42 opened 5 months ago

kxmh42 commented 5 months ago

Problem description

Pixi environments inside projects can be deleted at any time and regenerated using pixi.lock. However, it looks like it's not the case for environments created with pixi global install. If I delete $PIXI_HOME/envs, I have no way of recreating exact versions of the installed tools and their dependencies, is that right?

The particular scenario I'm looking at is saving space in my home folder by moving $PIXI_HOME/envs to a partition that has larger quota, but doesn't get backed up (see #997). And if $PIXI_HOME/envs is lost, I would like to recreate it in its exact state.

My suggestion would be to save lock files for global environments somewhere in $XDG_DATA_HOME/pixi / ~/.local/share/pixi.

ruben-arts commented 5 months ago

Currently the global environments are simple "non project" installs of a conda environment. So we don't save any information apart form the environment itself.

I unfortunately can't find the discussion but we've been talking about a configuration file for the global environments. E.g.:

envs:
  - name: bat
    channels:
      - conda-forge
    dependencies:
      - bat

  - name: ripgrep
    channels:
      - conda-forge
    dependencies:
      - ripgrep

  - name: some_pytorch_package
    channels:
      - conda-forge
      - pytorch
    dependencies:
      - some_pytorch_package
      - pytorch==2.3.1

This way you could easily track your global environments and even better recreate them on a new machine. These might then be extended with lock files per env to accommodate your request.

p.s. Not sure if we want to do this in YAML but my brain wrote it like that. Just take this as an example.

kxmh42 commented 5 months ago

Your example configuration file is an equivalent of pixi.toml. Personally, I don't see a need for such a file. pixi global is a package manager, and package managers usually don't have such configuration files. What I think would be useful is an equivalent of pixi.lock, to keep track of versions of packages and their dependencies, so that they can be reinstalled with exactly the same versions.

wolfv commented 5 months ago

@kxmh42 I think there are a few knobs users might want to turn in the "global" environemnts. For example, they might want to expose additional binaries or install additional (plugin) packages.

See #342 or #1017

Therefore we would likely come up with an additional config file that also does locking :)

kxmh42 commented 5 months ago

Ah, I see! In any case, if you do this, please don't save these config/lock files in $PIXI_HOME. Instead, put them in the appropriate XDG directories (config in $XDG_CONFIG_HOME/pixi, lockfile in $XDG_DATA_HOME/pixi, I guess?). This way, you can place $PIXI_HOME on a larger partition that is not backed up.

Edit: After reading the XDG spec, I believe the lockfile should be placed under $XDG_DATA_HOME, not $XDG_STATE_HOME.

ruben-arts commented 1 week ago

An update for this Issue, We've now implemented a manifest in https://github.com/prefix-dev/pixi/pull/1833

This will be the first step towards fixing this Issue. Would that already be enough for you?