Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishing an npm package with a specified binary does not install the binary when installed with npm #21303

Closed
eleith opened this issue Sep 30, 2022 · 1 comment · Fixed by #21372

Comments

@eleith
Copy link
Contributor

eleith commented Sep 30, 2022

Description

npm allows packages to install binary files through the use of the bin parameter as specified in their docs

using gitea's npm registry, i've noticed my packages will not install the binaries specified by it's package.json into the node_modules/.bin as it does with other packages on other registries.

i've only lightly investigated, but this may have some overlap with the solution to #21013

with npmjs registry, the bin is listed out in the registry metadata and also shows up when running npm info. as an example, ncu's registry shows that a bin property is listed out on each version

with gitea's registry, the bin property is missing (ex: https://example.com/api/packages/{owner}/npm/{@scope}/{package}) from the version field and thus also does not show up when running npm info

my current theory is that this missing metadata may be resulting in npm not knowing a package is providing a binary and thus not installing it post install.

however, if i link my package internally, the binary is picked up and installed correctly.

Gitea Version

1.17

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

docker compose

Database

PostgreSQL

@D0ms3y
Copy link

D0ms3y commented Oct 3, 2022

Ran into the same issue yesterday. I've compared the metadata of npmjs and my gitea npm registry. Adding the binary information in the metadata should fix this.

wxiaoguang pushed a commit that referenced this issue Oct 8, 2022
Fix #21303

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached
to the abbreviated version object:

https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial
implementation

this response is critical for npm to install the binary in the `.bin`
folder so as to be included on the users default bin path, resulting in
immediate access to any binaries provided by the package
lunny added a commit that referenced this issue Oct 25, 2022
backport of #21372 for v1.17.4

-------------------

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached
to the abbreviated version object:

https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial
implementation

this response is critical for npm to install the binary in the .bin
folder so as to be included on the users default bin path, resulting in
immediate access to any binaries provided by the package

i have tested upload and installing through npm and can confirm the npm
registry now responds with bin in the version metadata and results in
the binary being available after install.

this fixes #21303

Co-authored-by: eleith <online-github@eleith.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants