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

Wrong remote binary path break down mirror. #370

Closed
abcfy2 opened this issue Mar 5, 2023 · 5 comments · Fixed by #371
Closed

Wrong remote binary path break down mirror. #370

abcfy2 opened this issue Mar 5, 2023 · 5 comments · Fixed by #371

Comments

@abcfy2
Copy link
Contributor

abcfy2 commented Mar 5, 2023

Since v0.30.1 commit: 3351274

The binary mirror not working anymore.

npm_config_argon2_binary_host_mirror=https://cdn.npmmirror.com/binaries/argon2 npm i -dd argon2

Please revert remote host & path to the old version to fix mirror working. Thanks.

The prebuilt download URL should replace to https://cdn.npmmirror.com/binaries/argon2/v0.30.3/argon2-v0.30.3-napi-v3-linux-x64-glibc.tar.gz

A working example can referrer to sqlite3: https://github.com/TryGhost/node-sqlite3/blob/c1440bdaa47ffdda852ff576ac543114c4f0fb4b/package.json#L10-L20

@ranisalt
Copy link
Owner

ranisalt commented Mar 5, 2023

How did you find that exact commit is the culprit?

bcrypt and libxmljs use the same pattern as this repo with no issues. odbc uses yet another one.

@abcfy2
Copy link
Contributor Author

abcfy2 commented Mar 5, 2023

I used the old version before, and the mirror is working. But when I upgrade to the new version, the mirror no longer work.

And I find the wrong binary.host config in package.json, So I just find this file commit history, then I find it.

@abcfy2
Copy link
Contributor Author

abcfy2 commented Mar 5, 2023

From node-pre-gyp source code: https://github.com/mapbox/node-pre-gyp/blob/master/lib/util/versioning.js#L316

const host = process.env['npm_config_' + validModuleName + '_binary_host_mirror'] || package_json.binary.host;

download host can be override by environment variable npm_config_<module_name>_binary_host_mirror.

And from this file, we know download url is merged by host + remote_path + package_name.

Only host can be override by environment npm_config_<module_name>_binary_host_mirror or command line --<module_name>_binary_host_mirror <mirror_url>. So to make the mirror could work, we can't set {version} in host field. So your old code is correct:

  "binary": {
    "module_name": "argon2",
    "module_path": "./lib/binding/napi-v{napi_build_version}",
    "host": "https://github.com/ranisalt/node-argon2/releases/download/",
    "remote_path": "v{version}",
    "package_name": "{module_name}-v{version}-napi-v{napi_build_version}-{platform}-{arch}-{libc}.tar.gz",
    "napi_versions": [
      3
    ]
  },

And here is the npmmirror.com files list: https://registry.npmmirror.com/binary.html?path=argon2/

@ranisalt
Copy link
Owner

ranisalt commented Mar 5, 2023

Interesting. Not really an issue in this repo though, but rather a naming issue with this value which is not the host but something else.

I'm out of my PC right now, if you can open a PR I'll accept it right away, otherwise I can do it a little later.

@abcfy2
Copy link
Contributor Author

abcfy2 commented Mar 5, 2023

Got it, and here is the PR: #371

ranisalt pushed a commit that referenced this issue Mar 5, 2023
Make environment variable `npm_config_argon2_binary_host_mirror` or command line `--argon2_binary_host_mirror` could work.

Fix #370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants