Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm completion broken with corepack #8056

Closed
2 of 4 tasks
isaacl opened this issue May 6, 2024 · 3 comments
Closed
2 of 4 tasks

pnpm completion broken with corepack #8056

isaacl opened this issue May 6, 2024 · 3 comments

Comments

@isaacl
Copy link

isaacl commented May 6, 2024

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

brew install node corepack
corepack enable
corepack use pnpm@latest
echo '[[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true' >> .zprofile

restart shell

pnpm <tab tab>

Describe the Bug

Although tab tab completion script is loaded, it does not work properly.

Tab-tab behavior

~ pnpm <tab tab>
~ pnpm  ERR_PNPM_REDUNDANT_PARAMETERS \ The\ 1\ parameters\ after\ shell\ is\ not\ necessary

Completion debug:

# Note: I am using fnm, but I've verified this bug also exists in pure node/corepack setups
~ which pnpm
/Users/ilevy/Library/Caches/fnm_multishells/25073_1715009125780/bin/pnpm
~ print $_comps[pnpm]
_pnpm_completion
~ type _pnpm_completion
_pnpm_completion is a shell function from /Users/ilevy/.config/tabtab/zsh/pnpm.zsh
~ head -n5 /Users/ilevy/.config/tabtab/zsh/pnpm.zsh
###-begin-pnpm-completion-###
if type compdef &>/dev/null; then
  _pnpm_completion () {
    local reply
    local si=$IFS

Likely related to #7986.

Expected Behavior

pnpm completion works properly, even under corepack.

Which Node.js version are you using?

22.1.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@isaacl
Copy link
Author

isaacl commented May 6, 2024

Note that corepack uses a shim for pnpm, which is probably screwing up the arguments...

pnpm shim:

#!/usr/bin/env node
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='1'
require('./lib/corepack.cjs').runMain(['pnpm', ...process.argv.slice(2)]);

@KSXGitHub
Copy link
Contributor

KSXGitHub commented May 7, 2024

Are you using pnpm v9? pnpm v9 no longer uses tabtab for completion. Instead, you are supposed to uninstall tabtab from your .zprofile and then run pnpm completion zsh > $COMPLETION_SCRIPT or pnpm completion zsh >> ~/.zshrc.

The caveat, however, is that this method is not compatible with pnpm v8 while corepack can automatically switch between major pnpm versions. The only way and the only proper way to fix this is for corepack to provide its own completion script that would redirect commands to pnpm completion script (Like how completion script for sudo invokes completion script of the program it calls).

@isaacl
Copy link
Author

isaacl commented May 7, 2024

Yes I'm using pnpm v9 exclusively now.

Thanks for the tip, this fixed my issue.

@isaacl isaacl closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants