berry: [Bug] `dlx` on packages with a single binary doesn't execute it if the name doesn't match the package

  • I’d be willing to implement a fix

Describe the bug

I cannot run yarn dlx @yarnpkg/pnpify --sdk vscode with a private registry on Azure Artifacts.

Internal Error: Binary not found (pnpify) for root-workspace-0b6124@workspace:.

To Reproduce (Sherlock)

const installPromise = packageJsonAndInstall({
  dependencies: {
  },
});

// arrange private registry
await yarn(`config`, `set`, `npmRegistryServer`, `https://pkgs.dev.azure.com/it-casado/yarn-bugs/_packaging/yarn-bugs/npm/registry`);

await yarn(`config`, `set`, `npmRegistries["//pkgs.dev.azure.com/it-casado/yarn-bugs/_packaging/yarn-bugs/npm/registry"].npmAlwaysAuth`, `true`);
await yarn(`config`, `set`, `npmRegistries["//pkgs.dev.azure.com/it-casado/yarn-bugs/_packaging/yarn-bugs/npm/registry"].npmAuthIdent`, `eWFybi1idWdzOnM2Z2o3b3IzZGNicTY1cHVyZHdoZ282bnNoNnljZHRzMm43ZXZ3dG55YW8zc2lmb2F0bWE=`);

// act
const output = await yarn(`dlx`, `@yarnpkg/pnpify`, `--sdk`, `vscode`);

// assert
expect(output).not.stringContaining(`Internal Error: Binary not found (pnpify) for root-workspace`);

To Reproduce (Manual)

  1. .yarn.yml
npmRegistries:
  //pkgs.dev.azure.com/it-casado/yarn-bugs/_packaging/yarn-bugs/npm/registry:
    npmAlwaysAuth: true
    npmAuthIdent: eWFybi1idWdzOnM2Z2o3b3IzZGNicTY1cHVyZHdoZ282bnNoNnljZHRzMm43ZXZ3dG55YW8zc2lmb2F0bWE=

npmRegistryServer: "https:////pkgs.dev.azure.com/it-casado/yarn-bugs/_packaging/yarn-bugs/npm/registry"
  1. package.json
{
  "name": "SomeProject",
  "description": "Some project",
  "license": "MIT",
  "author": "Author",
  "version": "0.0.1",
  "devDependencies": {
    "typescript": "^4.0.3"
  }
}

Or use this GITHUB repository: https://github.com/IT-CASADO/yarn_issue_2013_repro

Side notes My authentication must be fine, because I can run yarn npm publish without any errors and I can see the published package on my private repository.

The used registry on Azure and the token (read-only) exists only for this bug. So there is no security issue here!

Using the default NPM repository works fine for me.

Environment if relevant (please complete the following information):

  • OS: [Windows]
  • Node version [10.18.3]
  • Yarn version [2.3.3]

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 42 (17 by maintainers)

Most upvoted comments

A quick workaround* is to set a custom scope just for @yarnpkg in your .yarnrc.yml:

npmScopes:
  yarnpkg:
    npmRegistryServer: "https://registry.yarnpkg.com"

*context: we had the same issue attempting to execute yarn dlx @yarnpkgdoctor in a repository exclusively using an Azure Artifacts feed with npm as the upstream.

There are two problems. One is the registry (it returns @yarnpkg/pnpify as binary name, which isn’t correct - the binary is called pnpify), one is Yarn (if there’s a single binary we should use it regardless of the package name, but we don’t).

FWIW, working on my team’s private repo, I was able to see this same issue, I initially saw it with when running yarn dlx @yarnpkg/doctor. When I comment out the azure registry items in my yarnrc.yml file, I am able to run the commands as expected

@arcanis I think you are talking here to a different issue (#1998). In this scenario I see:

➤ YN0027: @yarnpkg/pnpify@unknown can’t be resolved to a satisfying range: Internal Error: Invalid authentication (as an anonymous user)

If I copy my token to the project configuration or ~/.yarnrc.yml then I see the error: Internal Error: Binary not found (pnpify) for root-workspace-0b6124@workspace:.