Yarn publish does not work
Summary
A yarn publish
fails with a 404 when attempting to publish a package to the NPM registry. This looks it may be more of an issue with yarn, but I'm creating this issue in hopes we may be able to find a suitable workaround on our end.
Steps to reproduce
-
Create a project that has access to the NPM registry
-
Clone the project locally, then create a local
.npmrc
and adjust yourpackage.json
following the NPM Registry docs. -
Confirm npm publish is working as expected
-
Attempt a
yarn publish
Example Project
https://gitlab.com/calebw/npm-test2
(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)
What is the current bug behavior?
When attempting to use yarn publish
with an .npmrc
configured by following our documentation, yarn fails with the following error:
verbose 2.08239394 Performing "PUT" request to "https://gitlab.com/api/v4/packages/npm/@calebw%2fnpm-test2".
verbose 2.36987509 Request "https://gitlab.com/api/v4/packages/npm/@calebw%2fnpm-test2" finished with status code 404.
verbose 2.370948427 Error: Couldn't publish package: "https://gitlab.com/api/v4/packages/npm/@calebw%2fnpm-test2: 404 Not Found"
Yarn is attempting to PUT the package at the registry URL defined in the .npmrc
, which looks like the following (for my example project):
@calebw:registry=https://gitlab.com/api/v4/packages/npm/
If you adjust this line to use the /projects/:id/packages/npm/
endpoint instead, publishing packages with BOTH npm & yarn work, but attempting to install a package with this scope fails. The adjusted line looks like this (for this example project):
@calebw:registry=https://gitlab.com/api/v4/projects/16012851/packages/npm/
Yarn does support a --registry
flag for the publish command, wherein you can specify the registry to be published to, but this cannot be used for scoped registries. There is an open issue requesting this capability:
yarn publish should support --registry for scoped packages
What is the expected correct behavior?
Yarn publish succeeds with our recommended .npmrc
configuration.
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)
Output of checks
This bug happens on GitLab.com, as well as GitLab Enterprise Edition 12.7.0-pre f63a8586ef5
.
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 18.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.6.3p62 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 3.2.12 Git Version: 2.24.1 Sidekiq Version:5.2.7 Go Version: unknown
GitLab information Version: 12.7.0-pre Revision: f63a8586ef5 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.9 URL: https://gitlab.calebw.tech HTTP Clone URL: https://gitlab.calebw.tech/some-group/some-project.git SSH Clone URL: git@gitlab.calebw.tech:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 10.3.0 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)