Sharp: libvips binary download does not allow proxying of GitHub releases

Created on 27 Feb 2020  路  3Comments  路  Source: lovell/sharp

Did you see the documentation relating to installation?
Yes

Have you ensured the platform and version of Node.js used for npm install is the same as the platform and version of Node.js used at runtime?
N/A

If you are installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?
N/A

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?
N/A

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?
Checked and problem highlighted when it tries to download binary. Available on request.

What is the output of running npx envinfo --binaries --languages --system --utilities?
Available on request.


As we don't want to constantly redownload the binaries required by the sharp node module, we attempted to setup a proxy in our on-premise artifact server to the Github release URL for sharp-libvips. However we have found that this does not work as, if you override the Sharp Distribution Base URL, the version portion of the directory is not passed and therefore a 404 is received.

e.g. If you set SHARP_DIST_BASE_URL="https://artifacts.example.com/repository/node-sharp-binaries/, instead of looking for https://artifacts.example.com/repository/node-sharp-binaries/v8.9.0/libvips-8.9.0-darwin-x64.tar.gz, it tries to find https://artifacts.example.com/repository/node-sharp-binaries/libvips-8.9.0-darwin-x64.tar.gz.

This appears to be because at https://github.com/lovell/sharp/blob/master/install/libvips.js#L18 the code adds the version number to the base URL for the default GitHub URL but not for the overridden base URL. One could argue that you could add the required part of the directory to the base URL provided, but this isn't really easy to do when the sharp module is being used as a dependency on another module you are trying to install.

(Note that to make sure it isn't a proxy repo issue, I've manually curl'd the correct path from the proxy repo and I do successfully get the file back.)

enhancement

Most helpful comment

Happy to accept a PR that also allows the setting of a new environment variable that will insert the version number dynamically, if you're able. Please use npm_config_sharp_libvips_binary_host for this (so it matches the npm_config_sharp_binary_host pattern used for prebuilt sharp binaries).

This change will help people in China as I believe many are using the Taobao/Alibaba mirror at https://npm.taobao.org/mirrors/sharp-libvips

All 3 comments

Happy to accept a PR that also allows the setting of a new environment variable that will insert the version number dynamically, if you're able. Please use npm_config_sharp_libvips_binary_host for this (so it matches the npm_config_sharp_binary_host pattern used for prebuilt sharp binaries).

This change will help people in China as I believe many are using the Taobao/Alibaba mirror at https://npm.taobao.org/mirrors/sharp-libvips

馃憤Thanks - will look at putting something together.

v0.25.4 now available with sharp_binary_host and sharp_libvips_binary_host variables.

Please see the docs at https://sharp.pixelplumbing.com/install#custom-prebuilt-binaries for how to use these.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OleVik picture OleVik  路  3Comments

natural-law picture natural-law  路  3Comments

janaz picture janaz  路  3Comments

AVVS picture AVVS  路  3Comments

vermin1337 picture vermin1337  路  3Comments