Package managers cannot handle nested optionalDependencies

This commit is contained in:
Lovell Fuller 2023-10-07 11:09:45 +01:00
parent 68ac12292c
commit 51e56f994c
8 changed files with 12 additions and 27 deletions

View File

@ -9,6 +9,7 @@ const { familySync, versionSync } = require('detect-libc');
const { runtimePlatformArch, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
const runtimePlatform = runtimePlatformArch();
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
/* istanbul ignore next */
try {
@ -29,11 +30,15 @@ try {
help.push('Possible solutions:');
// Common error messages
if (prebuiltPlatforms.includes(runtimePlatform)) {
help.push(`- Add an explicit dependency for the runtime platform: "npm install --force @sharpen/sharp-${runtimePlatform}"`);
help.push('- Add explicit dependencies for the runtime platform:');
help.push(` npm install --force @sharpen/sharp-${runtimePlatform}`);
if (!isWindows) {
help.push(` npm install --force @sharpen/sharp-libvips-${runtimePlatform}`);
}
} else {
help.push(`- The ${runtimePlatform} platform requires manual installation of libvips >= ${minimumLibvipsVersion}`);
}
if (runtimePlatform.startsWith('linux') && /symbol not found/i.test(errPackage)) {
if (isLinux && /symbol not found/i.test(errPackage)) {
try {
const { engines } = require(`@sharpen/sharp-libvips-${runtimePlatform}/package`);
const libcFound = `${familySync()} ${versionSync()}`;
@ -41,16 +46,17 @@ try {
help.push(`- Update your OS: found ${libcFound}, requires ${libcRequires}`);
} catch (errEngines) {}
}
if (runtimePlatform.startsWith('darwin') && /Incompatible library version/.test(errLocal.message)) {
help.push('- Update Homebrew: "brew update && brew upgrade vips"');
if (isMacOs && /Incompatible library version/.test(errLocal.message)) {
help.push('- Update Homebrew:');
help.push(' brew update && brew upgrade vips');
}
if (errPackage.code === 'ERR_DLOPEN_DISABLED') {
help.push('- Run Node.js without using the --no-addons flag');
}
// Link to installation docs
if (runtimePlatform.startsWith('linux') && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
if (isLinux && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
help.push('- Using worker threads on Linux? See https://sharp.pixelplumbing.com/install#worker-threads');
} else if (runtimePlatform.startsWith('win32') && /The specified procedure could not be found/.test(errPackage.message)) {
} else if (isWindows && /The specified procedure could not be found/.test(errPackage.message)) {
help.push('- Using the canvas package on Windows? See https://sharp.pixelplumbing.com/install#canvas-and-windows');
} else {
help.push('- Consult the installation documentation: https://sharp.pixelplumbing.com/install');

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-darwin-arm64": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-darwin-x64": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-linux-arm": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-linux-arm64": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-linux-x64": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-linuxmusl-arm64": "0.0.1-alpha.1"
},
"files": [
"lib"
],

View File

@ -13,9 +13,6 @@
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@sharpen/sharp-libvips-linuxmusl-x64": "0.0.1-alpha.1"
},
"files": [
"lib"
],