1Password / op-js

A JS library powered by the 1Password CLI
https://developer.1password.com/docs/cli
MIT License
91 stars 8 forks source link

Cannot interact with the CLI on linux #123

Closed janmeier closed 2 months ago

janmeier commented 1 year ago

Your environment

op-js version: 0.1.8 CLI version: 2.17.0 OS: Ubuntu 22.04.2 LTS

What happened?

Trying to get an item from 1pass using item.get(id) I get

[ERROR] 2023/05/09 22:28:02 error initializing client: connecting to desktop app: read: connection reset, make sure the CLI is correctly installed and Connect with 1Password CLI is enabled in the 1Password app\n

What did you expect to happen?

To be able to get the item. Running op item get directly in the terminal works.

Steps to reproduce

Notes & Logs

This seems to be a linux only issue, my colleagues running osx don't have this issue.

I tried running require('child_process').spawnSync('op', ['item', 'get', 'XXX']) directly, to rule out any weirdness in op-js. and it gave the same error. Interestingly, if I replace spawn with exec: require('child_process').execSync('op item get XXX')), it works, so it seems to be something related to what process / env vars / whatever is inherited when spawning a new process using spawn, as opposed to running exec, which spawns a new shell

jodyheavener commented 1 year ago

Hey @janmeier thanks for reporting this issue! We haven't done a whole lot of testing of op-js in Linux, so this isn't too surprising, however I'd love to get this fixed up. I've added this to our team's radar to see if we can find a solution. Thank you!

hughrawlinson commented 1 year ago

I'm also experiencing this. For more data, I'm able to run op whoami in the cli and get a correct response, but when I call op.whoami() in node, I get the same error as shown above. I'm on Ubuntu 22.03, op-js: 0.1.8, cli version: 2.18.0. Let me know if you need any more data, or if you'd like me to try anything.

jodyheavener commented 4 months ago

Hey there! Apologies for the long delay on this.

I'm looking into this issue and have been able to successfully run op-js on my Ubuntu distro.

I am using this code, if you'd like to try it out yourself: https://github.com/jodyheavener/tmp-opjs-test

As for the error you are receiving, can you confirm that the 1Password desktop app is running and connected to the CLI?

jodyheavener commented 2 months ago

I'm going to close this issue for now. If the problem persists please feel free to re-open.