-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support cross-installing of prebuilt packages via npm_config_* vars #50
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Vincent Weevers <[email protected]>
// Instead, we just check whether a matching prebuild exists, and fail if it doesn't. | ||
require('./index').path() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Instead, we just check whether a matching prebuild exists, and fail if it doesn't. | |
require('./index').path() | |
// Instead, we just check whether a matching prebuild exists, and attempt to build if it doesn't. | |
try { | |
require('./index').path() | |
} catch (e) { | |
if (verbose()) console.error(e) | |
preinstall() | |
} |
I think it should be attempting to do a build instead of simply failing if there is no prebuild found.
If you are running for the same platform, it is likely that it will be possible to compile the binary.
Perhaps it should only attempt the build if the platforms match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having too many fallbacks makes behavior unpredictable. This PR makes a very reasonable assumption that if the platform doesn't match, compiling likely won't work. We still have --build-from-source
as an escape hatch.
Perhaps it should only attempt the build if the platforms match?
Not sure I understand the question. If the platforms match, then the behavior is the same as before (meaning: we find & test a prebuild, or build from source).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having too many fallbacks makes behavior unpredictable. This PR makes a very reasonable assumption that if the platform doesn't match, compiling likely won't work. We still have --build-from-source as an escape hatch.
Then this will be a breaking change. With 4.5.0 I can do a npm_config_arch=arm64 yarn
in my project and it compiles one dependency unnecessarily. With this change the same npm_config_arch=arm64 yarn
command fails, as one dependency doesn't provide prebuilds for linux-arm64.
I really shouldn't need to specify --build-from-source
and force the ci to recompile the multiple other native dependencies that have already have correct prebuilds
Not sure I understand the question. If the platforms match, then the behavior is the same as before (meaning: we find & test a prebuild, or build from source).
I mean that if I am trying to build linux-arm64
from linux-x64
, there is a reasonable chance that it will be able to compile it. But if I am trying to build win32-x64
from linux-x64
, is it worth even trying to perform that build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, you were talking about only a platform match, rather than both platform & arch. OK, if we keep this PR as-is (and I think we should, but I want to think about your use case for a bit) then we'll make it semver-major.
See vweevers/win-version-info#29 for context.
With this change, if
npm_config_platform
ornpm_config_arch
are set, and either one doesn't match the current machine, then the build isn't tested (since the test result will be wrong) and instead we just check if there's a matching prebuild available. If not, the install fails completely (because we can't easily cross-compile for targets like this).I've tested this in win-version-info with its win32-only prebuilds, disabling the
skip.js
test there, on Linux.Cross-installing for win32:
=> Correctly notices there's a valid win32 prebuild available, doesn't build anything, all good.
Cross-installing for a target with no prebuilds available:
=> Can't find a prebuild for the target platform, fails explicitly instead of building for the real platform incorrectly.