1Password / op-vscode

1Password for VS Code
https://marketplace.visualstudio.com/items?itemName=1Password.op-vscode
MIT License
218 stars 11 forks source link

CLI installed but not seen as such #31

Open remitbri opened 2 years ago

remitbri commented 2 years ago

Your environment

op-vscode version: v1.0.0

VS Code version: 1.68.1

CLI version: 2.5.1

OS: macOS 12.4

Steps to reproduce

  1. A VS Code window loads. Or I manually reload one.

What happened?

There's this "pop-up" (bottom right side) that says "CLI is not installed. Please install it to use 1Password for VS Code. Source: 1Password (Extension)", with a button "Open installation documentation".

What did you expect to happen?

A prompt to choose the vault, as the documentation says? Not this pop-up, at the very least

Notes & Logs

Typing op --version in a terminal (system, or VS Code's) gets "2.5.1"

jodyheavener commented 2 years ago

Hey @remitbri, thanks for filing and sorry you're experiencing this issue. From the details you provided it sure seems like everything should be functioning correctly.

You didn't install the CLI binary to a non-standard location by chance, did you? I don't think that should have an impact, but it would be worth ruling out. We're using lookpath to figure out if you have the CLI installed.

Finally, I'd recommend restarting VS Code if you haven't already, just to make sure it's a persistent issue. If restarting does fix it I'd still consider that a bug, but at least it would be working for you.

remitbri commented 2 years ago

Hi @jodyheavener Thanks for your reply. I've just created a local repo with just lookpath installed. Launching node

> const p = await lookpath('op')
undefined
> p 
'/usr/local/bin/op'

I installed op with homebrew, as per documentation.

jodyheavener commented 2 years ago

Thanks for verifying this on your end! This looks correct to me. I'll see what I can find out on my end.

jodyheavener commented 2 years ago

Hey @remitbri, while I haven't been able to uncover why the issue is occurring, someone else reported something similar and was able to resolve it by uninstalling and re-installing the extension. If you'd like to give that a try it could at least unblock you :)

remitbri commented 2 years ago

Removing+reinstalling didn't do the trick, nor did disabling/unabling, I had to remove the extension + quit VS Code + start VS Code + install the extension. It seems to be working as expected now…

remitbri commented 2 years ago

One workday later, the computer starts, VS Code starts and… the problem has come back, "CLI is not installed" etc

jodyheavener commented 2 years ago

Darn! Sorry to hear that, and thanks for following up to report this.

It's odd that it would work one day and not that next, so I'm curious: does VS Code ever present you with the message "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration."? If so, this could explain it; VS Code needs to establish your PATH through your shell in order to use the extension.

remitbri commented 2 years ago

It happens sometimes, but definitely not most of the times. I don't know why. It seems it's when I open a project from the terminal at the required folder, work on it, quit VS Code, and say the next day I reopen VS Code, the window of the project (will all the open tabs/files, etc) is already opened. If I ever get the "Unable to resolve…" message, it's then. But a simple reload (from the menu, "Developer: Reload Window") solves the issue. (I think the documentation says we should always open projects from their relevant folder in the terminal anyway)

Whereas I get the "CLI is not installed. …" error message each time at startup, or when I open a new window, or reload it

kitpierce commented 2 years ago

Having same issue with various CLI versions (including 2.4,x and 2.5.x) on Windows 10 and Windows 11. Definitely have installed the 1Password CLI in a custom location (for other development environment & business-case reasons.)

Would be nice to have an extension setting to specify a custom CLI binary path and still use the current 'lookpath' resolution method if this setting is undefined (likely would be for most users) or an invalid path.

alexclst commented 1 year ago

I've had the same problem across multiple versions of op, VS Code, and macOS. I have op installed via the brew cask, which installs the command into /usr/local/bin despite me being on an Apple Silicon Mac.

grapesmith commented 1 year ago

Having same issue with various CLI versions (including 2.4,x and 2.5.x) on Windows 10 and Windows 11. Definitely have installed the 1Password CLI in a custom location (for other development environment & business-case reasons.)

Would be nice to have an extension setting to specify a custom CLI binary path and still use the current 'lookpath' resolution method if this setting is undefined (likely would be for most users) or an invalid path.

Agreed - I can't edit my PATH variables (restricted account on my work computer), so I've added them to the VS Code user settings, but that doesn't seem to be recognized by the extension. Hard coding it would be a fine solution for me as well.

cbserra commented 1 year ago

So far, these ordered steps seem to have corrected the issue for me on macOS 13.1. I had already installed 1Password 8 and CLI 2 previously, so it was only a matter of removing the extension and making sure 1Password 8 and CLI 2 were configured correctly before re-installing the VS Code Extension:

  1. Remove 1Password for VS Code extension if installed.
  2. Make sure 1Password 8 for Desktop and 1Password CLI 2 are installed. I installed using Homebrew, and followed along with this page: Get started with 1Password CLI 2 . The binary was installed under /usr/bin/local/op
  3. The above link with instruct you to configure 1Password 8's Settings to configure Touch ID and CLI:
    1. Open 1Password.
    2. Click the account or collection at the top of the sidebar and choose Preferences > Security.
    3. Select Touch ID.
    4. Click Developer in the sidebar.
    5. Select "Connect with 1Password CLI".
    • You can also unlock 1Password CLI with your Apple Watch.
  4. In Terminal/iTerm I verified 1Password CLI was installed: op --version a. 2.13.0
  5. Then I attempted to signin via 1Password CLI: op signin, but received this error:
[ERROR] 2023/01/26 05:27:38 Lock the 1Password app to finish setting up Touch ID, then try again.
  1. I again executed op signin and received a different instruction:
[ERROR] 2023/01/26 05:27:57 1Password app is locked. Please open 1Password, unlock it with your password, and then try again
  1. After unlocking 1Password 8 app with my password, I ran op signin command a third time, and was finally presented with the Touch ID prompt within iTerm, and successfully connected my 1Password account with the CLI. You can execute op whoami to verify the correct account is signed into the CLI.
  2. Now, go back to VS Code and install the 1Password Extension. You may need to Reload VS Code. The error did not re-appear.

Hope this helps others! I also added the following to my .zshrc file (I believe all are also mentioned on the aforementioned site:

# 1Password CLI
eval "$(op completion zsh)"; compdef _op op # Adds shell completion commands for `op`
source ~/.config/op/plugins.sh # Adds aliases for `op` plugins to interface with various hosts like GitHub and Homebrew
jodyheavener commented 1 year ago

Thanks for this detailed information, @cbserra!

I'm just checking in on this. We haven't seen it come up consistently, and so @remitbri @kitpierce @alexclst I just wanted to check if you were still regularly experiencing this issue.

I'll note that, as requested above, we'll eventually be adding the ability to specify a custom CLI path, so if you continue to experience issues that could be a possible fix.

alexclst commented 1 year ago

I still see this fairly regularly.

jodyheavener commented 1 year ago

Thanks @alexclst! And I see you're on macOS from your last comment. One followup question: does this ever happen in conjunction with a warning from VS Code along the lines of "Unable to resolve your shell environment in a reasonable time"?

alexclst commented 1 year ago

@jodyheavener They aren't happening together. I very rarely get the warning about shell environment, but almost always the 1Password warning.

remitbri commented 1 year ago

@jodyheavener Hi! Running at the moment op-vscode v1.0.4 VS Code 1.76.0 CLI 2.14.0 macOS 13.2.1 So: I haven't observed the issue for quite a while, I don't think I did anything in particular about it

Regarding my zsh config files, I just have eval "$(op completion zsh)"; compdef _op op

jodyheavener commented 1 year ago

This issue is still ongoing and we don't yet have a solution, so I'm going to open this up to Hacktoberfest submissions if anyone is brave enough or has any wild ideas. Good luck!

legowerewolf commented 11 months ago

I'm currently getting this on Windows 11. 1Password CLI installed through winget. VSCode plugin version 1.0.4.

PS C:\Users\legowerewolf> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\Users\legowerewolf> get-command op

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     op.exe                                             0.0.0.0    C:\Users\legowerewolf\AppData\Local\Microsoft\WinGet\Links\op.exe

PS C:\Users\legowerewolf> op --version
2.22.0

EDIT: And just to make sure this isn't just Powershell being interesting, because god knows I'm doing weird crap in my Powershell profile, I checked in cmd.exe as well. Same result; op --version returns 2.22.0.

Perhaps it would help to add more diagnostic messaging in the extension's output? Right now, it just shows this: image

RenewedMe commented 11 months ago

I use MacOS 14.1.1 with CLI 2.23.0 and VScode 1.84.2 and extension 1.0.4 and I get the same error; I tried to uninstall, leave viscose and then try install again but I still get the same error message.

Do we know what makes the extension think the CLI is not installed?

kyrregjerstad commented 9 months ago

I'm experiencing the same issue: CLI is not installed. Please install it to use 1Password for VS Code. Extension version 1.0.4. I'm using a MacBook Pro M1 with macOS 14.2.1. Here's the output of the command op --version: 2.24.0. Installed it using homebrew. Both the standalone 1Password app and CLI function properly on their own.

JBG-brad commented 9 months ago

I'm experiencing the same issue: CLI is not installed. Please install it to use 1Password for VS Code. Extension version 1.0.4. Macbook Pro M3 14.3

Also installed via homebrew. No amount of uninstalling / reinstalling seems to make this work. ❯ op --version 2.24.0 ❯ which op /opt/homebrew/bin/op

Everything else functions just finer. The VS Code extension just won't believe the CLI is installed

JBG-brad commented 9 months ago

Well, right after posting this, I found the problem (at least on my machine).

It appears that when installing via homebrew, VSCode does not get nor prompt for full disk access.

Without it, lookpath can only access /usr/local/bin when the extension starts up. Other directories on $PATH seem to be forbidden.

Creating a symlink from /opt/homebrew/bin/op=>/usr/local/bin/op' or providing full disk access to VSCode solves the issue.

asheroto commented 3 months ago

Getting this issue on Windows. Have restarted. Have reinstalled 1Password CLI and also unchecked/checked CLI in main window.

Any ideas?