Skip to content

Yarn doesn't work with visual studio online package manager #2505

@lyweiwei

Description

@lyweiwei

Our team is using VSO package manager to manage our internal packages. It works fine with NPM, but fails with Yarn.

You can use this repository to reproduce the bug

git clone https://github.com/lyweiwei/yarn-with-vso
cd yarn-with-vso

# this would work
npm install --save @shazhouke/dummy-package

# this would fail
yarn add @shazhouke/dummy-package

Issue #2151 caused part of the problem. But even I hacked the auth for the resolving stage, it would still fail at downloading the tarball. The problem is, with VSO package manager, 1 account may have multiple feeds, and each of them has 1 registry. But all the registries under the account share the same package store.

With the example I gave, the registry is
https://shazhouke.pkgs.visualstudio.com/_packaging/shazhouke-private-npm/npm/registry
But the tarball is located at
https://shazhouke.pkgs.visualstudio.com/_packaging/42aaa647-fd03-4edd-baa1-d2b3f6ac2b16/npm/registry/@shazhouke/dummy-package/-/dummy-package-1.0.0.tgz

Note, the tarball URL doesn't begin with the registry URL. This condition would always be false.

if (this.token || (alwaysAuth && requestUrl.startsWith(registry))) {
  const authorization = this.getAuth(pathname);
  if (authorization) {
    headers.authorization = authorization;
  }
}

Seems we should assume the URL for resource of a given registry always begin with the registry URL.

I'm working on a patch to unblock our team and will create a PR when it's ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions