yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒

Home Page:https://yarnpkg.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug?]: yarn plugin import from sources fails

legobeat opened this issue · comments

Self-service

  • I'd be willing to implement a fix

Describe the bug

The docs for yarn plugin import from sources say:

The plugins can be referenced by their short name if sourced from the official Yarn repository.

Options

--repository #0
  The repository that should be cloned

This implies that it should be possible to install plugins from repositories other than the official Yarn repository. However, it does not seem like setting other name prefixes or repository URLs are actually supported.

To reproduce

Attempts:

$ yarn plugin import from sources --repository=https://github.com/example/example --branch=mypkg-v3 mypkg
➤ YN0051: Couldn't find a plugin named "@yarnpkg/plugin-mypkg" on the remote registry. Note that only the plugins referenced on our website (https://github.com/yarnpkg/berry/blob/master/plugins.yml) can be built and imported from sources.
➤ YN0000: Failed with errors in 0s 265ms

$ yarn plugin import from sources --repository=https://github.com/example/example --branch=mypkg-v3 @example/mypkg
➤ YN0001: Error: Invalid ident (@yarnpkg/plugin-@example/mypkg)
    at Object.Vs (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:140:109394)
    at /home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:2025
    at async Lt.start (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:176:1995)
    at async Xh.execute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:1902)
    at async Xh.validateAndExecute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:94:787)
    at async as.run (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:98:3250)
    at async oPt (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11303)
    at async nk (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11659)
➤ YN0000: Failed with errors in 0s 252ms

$ yarn plugin import from sources --repository=https://github.com/example/example @example/mypkg
➤ YN0001: Error: Invalid ident (@yarnpkg/plugin-@example/mypkg)
    at Object.Vs (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:140:109394)
    at /home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:2025
    at async Lt.start (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:176:1995)
    at async Xh.execute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:1902)
    at async Xh.validateAndExecute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:94:787)
    at async as.run (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:98:3250)
    at async oPt (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11303)
    at async nk (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11659)
➤ YN0000: Failed with errors in 0s 234ms

$ yarn plugin import from sources --repository=https://github.com/example/example
Unknown Syntax Error: Command not found; did you mean one of:

  0. yarn plugin import from sources [--path #0] [--repository #0] [--branch #0] [--no-minify] [-f,--force] <name>
  1. yarn plugin import from sources [--path #0] [--repository #0] [--branch #0] [--no-minify] [-f,--force] <name>

While running plugin import from sources --repository=https://github.com/example/example

$ yarn plugin import from sources --repository=https://github.com/example/example --branch=mypkg-v3 -f @example/mypkg
➤ YN0001: Error: Invalid ident (@yarnpkg/plugin-@example/mypkg)
    at Object.Vs (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:140:109394)
    at /home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:2025
    at async Lt.start (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:176:1995)
    at async Xh.execute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:473:1902)
    at async Xh.validateAndExecute (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:94:787)
    at async as.run (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:98:3250)
    at async oPt (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11303)
    at async nk (/home/node/.cache/node/corepack/v1/yarn/4.2.2/yarn.js:735:11659)
➤ YN0000: Failed with errors in 0s 249ms

$ yarn plugin import from sources --repository=https://github.com/example/example --branch=mypkg-v3 -f mypkg
➤ YN0051: Couldn't find a plugin named "@yarnpkg/plugin-mypkg" on the remote registry. Note that only the plugins referenced on our website (https://github.com/yarnpkg/berry/blob/master/plugins.yml) can be built and imported from sources.
➤ YN0000: Failed with errors in 0s 334ms

Environment

System:
    OS: Linux Debian 12 (bookworm)
    CPU: x64
  Binaries:
    Node: 20.14.0 - /var/tmp/xfs-4cd72c99/node
    Yarn: 4.2.2 - /var/tmp/xfs-4cd72c99/yarn
  npmPackages:
    jest: ^27.5.1 => 27.5.1

Additional context

Not clear if this is a case of misleading/incomplete docs or a gap in implementation. Is there a reason why users should actually not be able to install plugins of their own choosing from source?