Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
anishlr
3 years agoNew Contributor
Is it possible for 1Password CLI running on WSL to connect with 1Password hosted on Windows?
Right now I can access 1Password on my WSL Debian installation using the CLI. But I have to enter my master password even when Windows is authenticated. I was just curious if it's possible to connect...
yjo
5 months agoNew Contributor
One thing to be aware of if invoking the Windows op.exe from WSL: environment variables are not passed by default to Windows processes spawned from WSL (& vice versa). Some tools that integrate with the 1Password CLI rely on passing environment variables, e.g. OP_FORMAT
, which will result in issues if the tool is run from WSL.
In particular the 1Password Terraform provider (in one configuration) wraps the CLI, and relies on environment variables like OP_FORMAT=json
to configure it to give output that it can parse correctly. When running Terraform in WSL against a Windows CLI, these environment variables don't get passed to the spawned process, which means amongst other things that the CLI output is not JSON as the Terraform provider is expecting which causes things to fail with an error message like: "Unable to read vault, got error: invalid character 'I' looking for beginning of value"
.
Once I'd realised the cause of the issue, my workaround was to wrap the op.exe binary with a shell script that directs WSL to forward all OP_*
environment variables to Windows using the WSLENV
environment variable. My op
script sits next to op.exe
and looks like:
```bash
!/usr/bin/env bash
mapfile -d '' op_env_vars < <(env -0 | grep -z ^OP_ | cut -z -d= -f1)
export WSLENV="${WSLENV:-}:$(IFS=:; echo "${op_env_vars
exec op.exe "$@"
```
This solved my issue and I wanted to share in case anyone else is in the same situation, and to ask that this use case is considered if/when an official solution is implemented or documented!