1Password/Environment/Q/When using 1Password Environments, is there an easy way to load a variable from a 1Password secret?
Properties
- logseq-entity
- Logseq/Entity/Question
When using 1Password/Environments, is there an easy way to load a variable from a 1Password secret?
AI Answer
- Short answer: not inside the Environment itself, as of 2026-09-30. An Environment variable holds a literal value, and it cannot link to a field on a vault item. If you paste
op://vault/item/fieldas the value, the mounted.envhands back that string, not the secret. The easy way to get both today isop run, which reads an Environment and a file ofop://references in the same command. What the docs and forum say
- Answer/Official from Environments — 1Password Developer: variables are added by importing a
.envor by typing a name and value, and "1Password Environments return values exactly as they are entered." The docs never mention references to vault items. - The MCP server's own guide describes
append_variablesthe same way: each variable is a name, a value, and aconcealedflag. Nothing takes an item reference. - On the 1Password Community, users have asked for this since the 2025 beta, so they don't have to keep the same API key in a vault item and in an Environment. One user reported that importing a
.envof secret references stored the references as literal text. 1Password staff replied only that they passed the feedback on. (Frustrations with .env File Handling and Environments, 1Password Environments Beta is awesome)
- Answer/Official from Environments — 1Password Developer: variables are added by importing a
Workaround:
op runwith both sources- Answer/Official from op run — 1Password CLI reference:
--environmentand--env-filecan be passed together, andop runresolves theop://references in the file. - Keep the Environment for values that live only there, and put vault-backed ones in a committable file of references:
- Copy the Environment ID from the desktop app: Developer → View Environments → the Environment → Manage environment → Copy environment ID.
- Name clashes: when a name appears in both sources, the Environment wins, then the env file, then the shell. Define each name in only one place, or the stale Environment copy silently overrides the vault item.
- What you give up: this path goes through
opand a biometric prompt, not the mounted named pipe. A process that just opens.env, like adotenvloader, sees only the Environment's literal values.
- Answer/Official from op run — 1Password CLI reference:
Untested variant
- Store
op://…strings as the Environment's values, mount it, and runop run --env-file .env -- <command>against the mount.op runshould resolve the references it reads from the pipe, which keeps one list of names in the Environment and the values in vault items. No source confirms this, so try it on a throwaway Environment first.
- Store
- Short answer: not inside the Environment itself, as of 2026-09-30. An Environment variable holds a literal value, and it cannot link to a field on a vault item. If you paste