question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Cannot use binaries from scoped packages from gitlab npm registry

See original GitHub issue

Self-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

Playground

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: expect(received).rejects.not.toThrow(expected)

Expected substring: not "Command failed"
Received message:       "Command failed: /home/sandbox/.nvm/versions/node/v14.16.1/bin/node /sandbox/berry/scripts/actions/../run-yarn.js bin test-bin

Usage Error: Couldn't find a binary named \"test-bin\" for package \"root-workspace-0b6124@workspace:.\"

$ yarn bin [-v,--verbose] [--json] [name]
"


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:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jalopezcommented, Jul 28, 2021

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

0reactions
yarnbotcommented, Jul 28, 2021

This issue reproduces on master:

Error: expect(received).rejects.not.toThrow(expected)

Expected substring: not "Command failed"
Received message:       "Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js bin test-bin

Usage Error: Couldn't find a binary named \"test-bin\" for package \"root-workspace-0b6124@workspace:.\"

$ yarn bin [-v,--verbose] [--json] [name]
"


    at Object.toThrow (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0c0da74930.zip/node_modules/expect/build/index.js:242:20)
    at module.exports (evalmachine.<anonymous>:22:51)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
    at async Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to install published package - How to Use GitLab
I successfully published a package in a private repository of my organisation. In my global .npmrc I have the following:
Read more >
[BUG] Unable to install anything from a scoped private registry ...
I find no way to install anything from a private registry. I associated our scope with a registry, but then it gets completely...
Read more >
package.json - npm Docs
The names of scoped packages can begin with a dot or an underscore. ... If a url is provided, it will be used...
Read more >
How to troubleshoot NPM problems - JFrog
Using curl · NPM Login · NPM Install (Non-scoped) · NPM install (Scoped Packages) · NPM Publish · Dependency Rewrites.
Read more >
dealing with problematic dependencies in a restricted network ...
Package with install script or node-gyp dependency ... publishing a package to the public registry requires access to the public internet, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found