Skip to content

Commit

Permalink
Allow cross platform installation by --libc flag
Browse files Browse the repository at this point in the history
  • Loading branch information
xemle committed May 5, 2021
1 parent 070534d commit 73a248a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ When using npm v6 or earlier, the `npm install --unsafe-perm` flag must be used

When using npm v7, the user running `npm install` must own the directory it is run in.

When installing cross platform prebuilts on linux libc check can be overwritten by `--libc` flag, eg. `npm --arch=arm64 --libc= install`.

The `npm install --ignore-scripts=false` flag must be used when `npm` has been configured to ignore installation scripts.

Check the output of running `npm install --verbose sharp` for useful error messages.
Expand Down
5 changes: 3 additions & 2 deletions install/libvips.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ try {
// Is this arch/platform supported?
const arch = process.env.npm_config_arch || process.arch;
const platformAndArch = platform();
const libcFamily = typeof process.env.npm_config_libc !== 'undefined' ? process.env.npm_config_libc : detectLibc.family;
if (arch === 'ia32' && !platformAndArch.startsWith('win32')) {
throw new Error(`Intel Architecture 32-bit systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
}
Expand All @@ -96,12 +97,12 @@ try {
if (platformAndArch === 'freebsd-x64' || platformAndArch === 'openbsd-x64' || platformAndArch === 'sunos-x64') {
throw new Error(`BSD/SunOS systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
}
if (detectLibc.family === detectLibc.GLIBC && detectLibc.version) {
if (libcFamily === detectLibc.GLIBC && detectLibc.version) {
if (semverLessThan(`${detectLibc.version}.0`, `${minimumGlibcVersionByArch[arch]}.0`)) {
throw new Error(`Use with glibc ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`);
}
}
if (detectLibc.family === detectLibc.MUSL && detectLibc.version) {
if (libcFamily === detectLibc.MUSL && detectLibc.version) {
if (semverLessThan(detectLibc.version, '1.1.24')) {
throw new Error(`Use with musl ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`);
}
Expand Down

0 comments on commit 73a248a

Please sign in to comment.