Skip to content

Please check the value instead of simply the presence #4490

@ardelio

Description

@ardelio

if (useGlobalLibvips() || process.env.npm_config_build_from_source) {

Other packages, such as gdal-async, use this variable as a mechanism to indicate to the package that it must build from source. Said packages, as a convention, look for the presence of their package name within the value which is a more robust implementation that plays nice within the ecosystem, than simply looking at the presence of the env var.

It would be most excellent if Sharp could do the same, e.g.:

const buildFromSource = process.env.npm_config_build_from_source;

if (useGlobalLibvips() || (buildFromSource && buildFromSource.includes('sharp'))) {
    process.exit(1);
  }

This would improve the install experience and prevent consumers from having to install and rebuild in multiple steps to overcome Sharp's implementation.

For example, we have to do the equivalent of the following:

// Installs sharp as we would like, but gdal-async is not bound to our versions of gdal
npm install

// Rebuild Gdal Async bound to our versions of GDAL.
npm_config_build_from_source=gdal-async npm_config_shared_gdal=true npm rebuild gdal-async

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions