Using activate with sudo breaks later activations without sudo
See details in https://flox-dev.slack.com/archives/C05P6A5J6U8/p1745950722575169?thread_ts=1745950512.156669&cid=C05P6A5J6U8
Sounds like
sudo flox activate
flox activate
results in
Error: Permission denied (os error 13)
This appears to have been caused by root owning .cache/flox/run/fa51161e/activations.json
We're treating ~/.cache/flox/run as XDG_RUNTIME_DIR, which per XDG spec:
The directory MUST be owned by the user, and they MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700
We may need to check how we're determining the directory when running as root
We may need to check how we're determining the directory when running as root
It's not just root - root is just the user that has the power to corrupt the cache, while all others will see a failure. In general we'll need to use geteuid() to identify the effective UID as part of deciding where to put these files.
We should verify whether we still need to reset USER and HOME at the same time after https://github.com/flox/flox/pull/3191
Running into this when trying to set up Flox inside containers for background agents. The agent operates everything as the default user (ubuntu in this case), however because it's in a container the Flox environment needs to be built as root, and so we're currently unable to use flox for this purpose.
Occurrence from the wild: https://flox-dev.sentry.io/issues/7034292544/?project=4506548241825792