openupm-cli icon indicating copy to clipboard operation
openupm-cli copied to clipboard

Installation of Scoped Registry for Gitlab Projects fails

Open Blackclaws opened this issue 2 years ago • 4 comments

Gitlab while not allowing searching of packages does allow hosting of packages at least on project level under a path like:

gitlabHost/api/v4/projects/projectID/packages/npm/

I tried to set up such a scoped registry using openupm-cli:

npx openupm-cli --no-upstream -v -r https://redactedURL/api/v4/projects/39/packages/npm/ add redactedPackageName

however openupm does not try to authenticate and then just shows the package as 404:

verb request no auth needed
SNIP
ERR! 404 package not found:

I haven't looked into the code and it might be that openupm-cli just tries to search for the package first, which fails because gitlab does not support searching for packages.

Adding the package manually into manifest.json and setting up the scoped registry manually works fine.

I should also add that installing the package via npm into any directory also works fine.

Blackclaws avatar Jul 15 '21 19:07 Blackclaws

Hi @Blackclaws,

Thanks for reporting the issue. I'm not a GitLab user, so could you provide a public testable URL (from you or others), so I can test it?

favoyang avatar Jul 16 '21 17:07 favoyang

I'll see what I can do. The non self-hosted instance only supports scoped packages which upm does not accept anyway. I'll get back to you on that.

Blackclaws avatar Jul 19 '21 14:07 Blackclaws

I've debugged this a bit more. It turned out to actually be an issue of how the --registry flag is parsed vs how its written in the .upmconfig

The registry command line option strips off the final / in the path because its added back in. When looking for auth entries it will not match an entry that has a final slash set as it was in my .upmconfig

This is a bit nontrivial to debug, one possible solution is to apply the same stripping logic to the urls retrieved from the .upmconfig.

If you'd like I'll submit a pull request, this is a general issue with registries that are defined with authentication including a final slash in .upmconfig

Blackclaws avatar Sep 08 '21 12:09 Blackclaws

This is a bit nontrivial to debug, one possible solution is to apply the same stripping logic to the urls retrieved from the .upmconfig.

Oh, that's a good catch.

If you'd like I'll submit a pull request, this is a general issue with registries that are defined with authentication including a final slash in .upmconfig

It seems a good solution. PR is welcome.

favoyang avatar Sep 08 '21 13:09 favoyang

@all-contributors please add @Blackclaws for bug.

favoyang avatar Jan 20 '24 05:01 favoyang

@favoyang

I've put up a pull request to add @Blackclaws! :tada:

allcontributors[bot] avatar Jan 20 '24 05:01 allcontributors[bot]