1

I have been using pass for some time to store passwords, but now I want to move my password store from the default location. According to the man page, it is enough to set PASSWORD_STORE_DIR variable to the desired path to override the default one, however in my case this has no effect. After I move the .password-store folder to a new location and set the environment variable, executing the command pass results in "Error: password store is empty. Try "pass init".". Even if simply renaming the .password-store inside home directory:

$ cd
$ mv .password-store .pass
$ PASSWORD_STORE_DIR=/home/bakhtin/.pass #bakhtin is the user name
$ pass
Error: password store is empty. Try "pass init".

Any ideas on what the problem might be? I made sure the are no spelling errors in the variable's name and such.

2
  • 1
    Is the variable PASSWORD_STORE_DIR exported?
    – Kusalananda
    Oct 8, 2022 at 13:34
  • Thanks, that was the problem. I am still new to the logic of environment variables, so forgot that exporting is a thing.
    – Alexander
    Oct 8, 2022 at 13:46

1 Answer 1

0

Since the variable and its value need to be accessed by pass, a process started from the shell and running separately from it, the variable needs to be an environment variable. Environment variables are inherited by child processes, but other shell variables are not inherited.

In your case, you have simply forgotten to use export on the PASSWORD_STORE_DIR variable to tag it as an environment variable.

export PASSWORD_STORE_DIR=~bakhtin/.pass

You may also use just export PASSWORD_STORE_DIR to mark the variable as an environment variable if you have already assigned a value to it.

Another way to pass the variable into the environment of pass without even creating it as a shell variable in the invoking shell is to write the assignment in front of the invocation of pass:

PASSWORD_STORE_DIR=~bakhtin/.pass pass

This sets the variable's value for the pass process but does not create a variable in the current shell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .