-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(run): Add engines check before executing scripts. #7021
Conversation
@@ -229,11 +229,12 @@ const messages = { | |||
nodeGypAutoInstallFailed: | |||
'Failed to auto-install node-gyp. Please run "yarn global add node-gyp" manually. Error: $0', | |||
|
|||
foundIncompatible: 'Found incompatible module', | |||
foundIncompatible: 'Found incompatible module.', |
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.
Looks like this was the odd one out, so added some punctuation 🤓
|
I'm unsure why Flow fails. My changes are in that file, but otherwise they seem unrelated, to my naive Flow eyes. |
try { | ||
await checkCompatibility({_reference: {}, ...pkg}, config, ignoreEngines); | ||
} catch (err) { | ||
throw err instanceof MessageError ? new MessageError(reporter.lang('cannotRunWithIncompatibleEnv')) : err; |
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.
This refines a, in this context, vague error.
I put these same comments in Discord chat, but I'll paste them here too for tracking with this PR: wow, I don't know how it came up with that error message for that line, but...
you are assigning Function signature is:
|
Wow, indeed! I don’t even understand how you were able know what it was really complaining about 😅
I see. At first I just passed Based on that, clearly the reference isn’t actually required, so I’m going to remove the |
4eb6391
to
135863e
Compare
if you remove the You'll probably have to change the
for Flow to let it pass. I think that makes more sense than the invariant anyway, since
The code should work whether or not |
@rally25rs Yup, I added that guard, but I squashed my commits so maybe it's not clear that I pushed new changes. Sorry about that. |
@rally25rs bump, can I get another review? 🙏 |
@@ -744,7 +744,7 @@ export class Install { | |||
|
|||
async checkCompatibility(): Promise<void> { | |||
const {manifest} = await this.fetchRequestFromCwd(); | |||
await compatibility.checkOne({_reference: {}, ...manifest}, this.config, this.flags.ignoreEngines); | |||
await compatibility.checkOne(manifest, this.config, this.flags.ignoreEngines); |
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.
what does this change do? 🤔
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.
This was needed to avoid hitting that same invariant that I did.
Just fixed a new merge conflict. Is there anything I can do to move this forward? |
Thanks! |
Closes #7013
Summary
A more elaborate description is available in #7013. In short, ensuring scripts are ran in the expected environment can deter hard to diagnose bugs.
Test plan
Given a
node
engine requirement that doesn’t match the current environment:A script invocation will fail as follows:
If need be, this can be overridden with the
--ignore-engines
flag:Or, of course, making the environment match the requirements: