Upgrading flox breaks default environment

Upgrading from 0.0.5-r31 to 0.0.6-r45 broke the default environment.

flox activate
INFO environment not found: /home/fps/.local/share/flox/environments/local/default
INFO environment not found: /home/fps/.local/share/flox/environments/local/default

flox list -e default shows no installed Packages, only the env metadata:

local/default
    Alias     local/default
    System    x86_64-linux
    Path      /home/fps/.local/share/flox/environments/local/default
    Curr Gen  9

Packages

Looking at the location of the env, I tried

file .local/share/flox/environments/local/default

saying

.local/share/flox/environments/local/default: broken symbolic link to default-9-link

Hi @fleimgruber !
Thanks for pointing this out. Looking into it, I have a few questions:

  • did you flox push your environment at any point? If so a flox pull should set your env back up.
  • did you perform any garbage collection on your envs? This could delete a package necessary for that env if it didn’t have a GCRoot any longer.
  • can you still see symlinks under .local/share/flox/environments/local/ ?

Thanks,
Julien

Hi @jurraca, thanks for looking into it!

did you perform any garbage collection on your envs?

I did an upgrade (on 22.05 channel) via nixos-rebuild switch --upgrade and after reboot I did nix-store --gc and nix-collect-garbage -d after nix-env --delete-generations old.

can you still see symlinks under .local/share/flox/environments/local/ ?

Yes:

ls ~/.local/share/flox/environments/local/
default  default-4-link  default-5-link  default-6-link  default-7-link  default-8-link  default-9-link  work  work-1-link

and

file default-9-link
.local/share/flox/environments/local/default-9-link: broken symbolic link to /nix/store/38icd9ys4m7vlr0fcl18v3agq4dpizxn-profile

which looks like you were right about the missing GCRoot?

How should I proceed? Did I miss that in the docs? Can we exclude packages from GC that are referenced by flox?

How should I proceed? Did I miss that in the docs?

You did not miss it, we should provide some documentation around this.
In short, the packages are gone, but the metadata which defines your environments is not.

The easiest way to recover your environments would be to push your environments up to github via flox push and flox pull them back down (docs). I’d recommend stashing your environments this way, never know when (or where) you may need them :slight_smile: .

Another way to recover is to run flox edit to edit your manifest. Currently editing the manifest will force an upgrade to all packages in the environment, effectively re-rendering the env locally (adding a whitespace will suffice). If you don’t want to upgrade, go with the first option.

Can we exclude packages from GC that are referenced by flox?

Not currently, but we are working on handling GC better and should have some updates on this front soon. Look out for the release notes.

Let me know if you run into any issues with this!

Thanks for checking back! Is Gitlab supported for hosting environments? If not, how can I re-configure flox push? It let me choose Gitlab from a list, but it seems Gitlab can’t be configured e.g. via flox gl auth login, so now it appears it always wants to push to Gitlab - I did the Github auth after selecting Gitlab from that list…

GitLab is supported, but we don’t ship the GitLab CLI with flox like we do with gh.
In the third step here, it asks you to confirm the URL, and you should input the gitlab URL, not the default.
If you haven’t messed with your config too much, a flox config --reset should be harmless and get you out of that loop. Just go back to flox push and with the prompt select GitLab, HTTPS, and the GitLab URL.
You’ll need to set up the GitLab token or similar auth in your shell somehow.

flox config --reset should be harmless and get you out of that loop. Just go back to flox push and with the prompt select GitLab, HTTPS, and the GitLab URL.

flox config --reset did not work unfortunately.

@fleimgruber under the hood this is a git repository, so the changing of its location can be done via (if using git via SSH auth):

$ flox git remote set-url origin git@gitlab.com:USERNAME/floxmeta
$ flox push

You need to ensure that your Gitlab authentication is set up the way you like, if you are using https auth then https://gitlab.com/USERNAME/floxmeta and so forth.

Note: also, you would need to create that empty repo yourself.

OK, sorry about that.
You can actually check your remote for the floxmeta repo with flox git remote -v.
And you can then replace the origin with git as you would with git (flox git remote add origin https://gitlab.com/myrepo).
Let me know if that doesn’t sort you out.

Thank you both for the helpful answers, I could sort it out and the default environment works again!

4 Likes