[Bug]: Cannot use binaries from scoped packages from gitlab npm registry
See original GitHub issueSelf-service
- I’d be willing to implement a fix
Describe the bug
When using a scoped package coming from a custom registry (gitlab, for instance), if the package provides a binary, it is not recognized by yarn (running yarn bin doesn’t return it). The package is properly installed though, and if using node-modules linker, the binary can be found in node_modules/.bin but it is not possible to run it properly with yarn run.
To reproduce
Example scoped package in custom registry with a binary: https://gitlab.com/javier.lopezpardo-cabify/test-private, and a client trying to use it: https://gitlab.com/javier.lopezpardo-cabify/test-private-client
const {promises: {writeFile, access}} = require(`fs`);
await writeFile('.yarnrc.yml', `
nodeLinker: node-modules
npmScopes:
javier.lopezpardo:
npmRegistryServer: "https://gitlab.com/api/v4/projects/28429944/packages/npm/"
npmPublishRegistry: "https://gitlab.com/api/v4/projects/28429944/packages/npm/"
`)
await packageJsonAndInstall({
dependencies: {
[`@javier.lopezpardo/test-private-bin`]: `0.0.1`
},
});
await expect(access('./node_modules/.bin/test-bin')).resolves.not.toThrow()
await expect(yarn('bin', 'test-bin')).rejects.not.toThrow('Command failed')
Output:
Error: [2mexpect([22m[31mreceived[39m[2m).[22mrejects[2m.[22mnot[2m.[22mtoThrow[2m([22m[32mexpected[39m[2m)[22m
Expected substring: not [32m"Command failed"[39m
Received message: [31m"[7mCommand failed[27m: /home/sandbox/.nvm/versions/node/v14.16.1/bin/node /sandbox/berry/scripts/actions/../run-yarn.js bin test-bin[39m
[31m[39m
[31mUsage Error: Couldn't find a binary named \"test-bin\" for package \"root-workspace-0b6124@workspace:.\"[39m
[31m[39m
[31m$ yarn bin [-v,--verbose] [--json] [name][39m
[31m"[39m
at Object.toThrow (/sandbox/node_modules/expect/build/index.js:242:20)
at module.exports (evalmachine.<anonymous>:22:51)
at async /sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
at async executeInTempDirectory (/sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
at async executeRepro (/sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
at async module.exports../pages/api/sherlock.js.__webpack_exports__.default (/sandbox/.next/server/static/development/pages/api/sherlock.js:140:29)
at async Object.apiResolver (/sandbox/node_modules/next/dist/next-server/server/api-utils.js:46:9)
at async DevServer.handleApiRequest (/sandbox/node_modules/next/dist/next-server/server/next-server.js:449:9)
at async Object.fn (/sandbox/node_modules/next/dist/next-server/server/next-server.js:371:37)
at async Router.execute (/sandbox/node_modules/next/dist/next-server/server/router.js:134:32)
at async DevServer.run (/sandbox/node_modules/next/dist/next-server/server/next-server.js:491:29)
at async DevServer.handleRequest (/sandbox/node_modules/next/dist/next-server/server/next-server.js:144:20)
Environment
System: OS: macOS 11.4 CPU: (4) x64 Intel® Core™ i7-7660U CPU @ 2.50GHz Binaries: Node: 14.15.1 - /private/var/folders/_k/xn52qc7s0rn72kn1l3l9x_lw0000gn/T/xfs-7ea0d20f/node Yarn: 3.0.0 - /private/var/folders/_k/xn52qc7s0rn72kn1l3l9x_lw0000gn/T/xfs-7ea0d20f/yarn npm: 6.14.8 - ~/.volta/tools/image/node/14.15.1/bin/npm
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)

Top Related StackOverflow Question
I’ve rephrased the issue title to ease finding it in case someone else looks for it.
Just for clarification, this bug is already being tackled by gitlab team. More info https://gitlab.com/gitlab-org/gitlab/-/issues/275992
This issue reproduces on master: