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

fix: return only boolean when useGlobalLibvips is used by gyp #4111

Closed
wants to merge 1 commit into from

Conversation

project0
Copy link
Contributor

@project0 project0 commented May 22, 2024

The debug log is compromising the gyp variable use_global_libvips and therefore breaks compilation when the detection adds additional output.

/app/node_modules/sharp # SHARP_FORCE_GLOBAL_LIBVIPS=true node -p "Boolean(require('./lib/libvips').useGlobalLibvips()).toString()" 
sharp: Detected SHARP_FORCE_GLOBAL_LIBVIPS, skipping search for globally-installed libvips
true

see also #4060 and 579cf93

@project0 project0 force-pushed the fix/install-script branch from 90debdb to 8e60427 Compare May 22, 2024 09:23
@lovell
Copy link
Owner

lovell commented May 22, 2024

Thanks for the PR. Given the "skipping search for globally-installed libvips" log message is somewhat confusing when SHARP_FORCE_GLOBAL_LIBVIPS is set, could this be simplified to something like the following?

+++ b/lib/libvips.js
@@ -172,7 +172,7 @@ const useGlobalLibvips = () => {
     return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS');
   }
   if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
-    return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS');
+    return true;
   }
   /* istanbul ignore next */
   if (isRosetta()) {

@project0
Copy link
Contributor Author

project0 commented May 22, 2024

i guess it could, but at the same time it is a helpful information that the detection is enforced/influenced by the env variable.

@project0
Copy link
Contributor Author

project0 commented May 22, 2024

Also, given the output is used in a script we already got lucky as we never checked for the false value.

The debug log is compromising the gyp variable use_global_libvips and
therefore breaks compilation when the detection adds additional output.
@project0 project0 force-pushed the fix/install-script branch from 8e60427 to 9cbcf8d Compare May 23, 2024 08:21
lovell added a commit that referenced this pull request May 24, 2024
Allows the install/check script to inject a logger function,
keeping its use within binding.gyp free of additional output.

Co-authored-by: Lovell Fuller <[email protected]>
@lovell
Copy link
Owner

lovell commented May 24, 2024

we already got lucky

Ha ha, yes, this is a good point well made.

I've inverted the logic slightly to inject a logger function, which I think makes it a bit easier to test. This landed as 56fae3e

Thanks again for taking the time to open a PR for this.

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 this pull request may close these issues.

2 participants