Unable to activate a postgres flox environment

Hi,

I’m trying to run the a simple postgres flox environment from floxhub on my m1 mac machine. However, it fails to activate with the -start-services flag.
I’ve pulled the env by using ’ flox pull flox/postgres ’

Then, I’m activate it by using ‘flox activate --start-services’
however it fails by saying:

Error: failed to acquire lockfile

Caused by:
0 : failed to open lockfile
1 : Permission denied (os error 13)

to facilitate the creation, i’ve enabled all the read and write rights for all users for
/Users/{user-name}/.local/share/flox/env-registry.json and env-registry.lock files.

What can i do to get the postgres instance running on my machine ?

Please let me know.

Hej Vishnu

Thanks for giving flox a try, sorry you are having troubles.
Would you be able to check what value $XDG_RUNTIME_DIR has (if set) or otherwise $XDG_CACHE_HOME?

The values of the environment variables are empty. Activating the terminal does not set the values of the variables either.

Thank you, then you should be using the defaults, but to be sure I think flox config should include “runtime_dir”.

Could you check the permissions on that, or if that isn’t there, $HOME/.cache/flox/run?

Thanks for the reply.
There is no entry for runtime_dir when ‘flox config’ is entered in the terminal.

The permissions on ‘$HOME/.cache/flox/run’ are drwxr-xr-x

Does it need write permissions as well ?

Hmm interesting, yes you need write access to the cache dir and the files in it.
Unless you are not the owner of the dir the permissions look correct.

Basically flox tries to read $HOME/.cache/flox/run/<hash/ident if your env>/activations.json and ostensibly fails to do so.

Is the home dir shared somehow that user permissions don’t suffice?

I assume you also didn’t activate without services before right?

The home directory is not shared with any other users. It’s my the home directory after I login to the system with my username.

I activated before with services. However, I could not run postgres as it refuses to run with root previlages. So, i had to activate as a regular user.
When so, I get this message.

Did you happen to run flox with root/sudo?
If so you may have created root owned caches that your regular user can’t read anymore.

Yes, I’m able to create the postgres environment as regular user if reinstall flox as regular user (not as a root using ‘sudo’ command). I must have installed flox as a root user and so i was running into all sorts of permission issues.

Thanks for walking me through the solution and giving pointers as needed. Your direction is much appreciated.

Just an FYI, I’m test driving flox on my dev machine and it’s looking good, we’re doing further testing with different scenario’s. If all goes well, we’ll adopt it as a go-to solution for onboarding new developers. :slight_smile:

Glad we got that resolved.
I’m curious what may have led flox to run as root, if it was too easy to create all sorts of permission issues we might want to improve our documentation or runtime checks on that.

Just an FYI, I’m test driving flox on my dev machine and it’s looking good, we’re doing further testing with different scenario’s. If all goes well, we’ll adopt it as a go-to solution for onboarding new developers

That sounds great! Welcome to reach out if you have any further issues.