pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Pkg: FLAGS_MISMATCH when I run the packaged app.

Open liweiz opened this issue 8 years ago • 18 comments

It's most likely some misunderstanding on my side since I did not find any information of this by googling and searching the issues here.

Every time I run the packaged app, I got the warning:

"Pkg: FLAGS_MISMATCH"

I tried only using a index.js file with only the argv print operation.

process.argv.forEach(function(val, index, array) {
  console.log(index + ': ' + val);
});

Run

pkg index.js -t macos

And run the packaged app, still the same result.

My node version: v10.7.0. pkg version is 4.3.3.

liweiz avatar Jul 30 '18 14:07 liweiz

Ran into this when I added --options prof to the pkg command.

markus456 avatar Aug 20 '18 12:08 markus456

you may also check if there is NODE_OPTIONS environment variable set

hshixun avatar Sep 07 '18 10:09 hshixun

@hshixun Thanks, will check that var next time.

liweiz avatar Sep 09 '18 01:09 liweiz

Running into this over at https://github.com/lando/lando

We compile lando with pkg without settings any v8 options. If a user exports NODE_OPTIONS to anything (eg export NODE_OPTIONS=--max_old_space_size=4096) then tries to run lando it results in "Pkg: FLAGS_MISMATCH".

Is there a way to compile lando so that a user's NODE_OPTIONS is ignored if set to something mismatched?

pirog avatar May 09 '19 04:05 pirog

Any update on this?

Seems like an enormous bug... anyone with the NODE_OPTIONS env var set cannot invoke executables compiled with pkg.

It also seems easy to fix. Can pkg simply clear the NODE_OPTIONS env var when invoking the bundled node at runtime? For reference, node itself complains about FLAGS_MISMATCH.

jchook avatar Sep 29 '19 17:09 jchook

I'm keen for an update, too. Having to unset NODE_OPTIONS each time is getting real old!

azzamaurice avatar Nov 11 '19 22:11 azzamaurice

This is breaking my balls as well.

soniktrooth avatar Nov 11 '19 22:11 soniktrooth

Lol this is stupid. It seems to work if you compile it with options though e.g.

pkg . --options max_old_space_size=4096

ayroblu avatar May 03 '20 13:05 ayroblu

It really doesn't seem like the solution should be to set every possible option in pkg. Do we know a list of options which are being set?

Is there some reason the current environment can't be detected and override whatever pkg defaults to?

MGibson1 avatar Mar 10 '21 20:03 MGibson1

Revising my initial suggestion, could the bundled binary simply invoke node with the options provided by the host's NODE_OPTIONS env var?

jchook avatar Mar 12 '21 01:03 jchook

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Jun 11 '21 00:06 github-actions[bot]

Anyone with the NODE_OPTIONS env var set cannot invoke executables compiled with pkg.

jchook avatar Jun 11 '21 00:06 jchook

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Sep 10 '21 00:09 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar Sep 16 '21 00:09 github-actions[bot]

With latest Node 16, the binary built with pkg exits immediately. We have no warning "Pkg: FLAGS_MISMATCH".

strace ./my_pkg_program ends with:

rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
exit_group(4)                           = ?
+++ exited with 4 +++

It works if you unset NODE_OPTIONS env:

NODE_OPTIONS="" ./my_pkg_program

I leave this comment mainly to help users to find the solution, hoping search engines will guide them here 🙂.

dgrelaud avatar Nov 17 '21 16:11 dgrelaud

Can someone with pkg experience help us understand:

Is this an easy fix? i.e. can pkg simply pass NODE_OPTIONS="" into node?

jchook avatar Nov 17 '21 23:11 jchook

With latest Node 16, the binary built with pkg exits immediately. We have no warning "Pkg: FLAGS_MISMATCH".

strace ./my_pkg_program ends with:

rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
exit_group(4)                           = ?
+++ exited with 4 +++

It works if you unset NODE_OPTIONS env:

NODE_OPTIONS="" ./my_pkg_program

I leave this comment mainly to help users to find the solution, hoping search engines will guide them here 🙂.

I spent like 5ish hours today trying to figure this out and I'm glad you all verified I'm not crazy haha. My goal was to dynamically set the heap size based on some bash-fu aimed at exporting NODE_OPTIONS.

@jchook thanks for keeping this alive, maybe there's a fix by now 🤞 haha.

marquiswashere avatar Jan 07 '22 02:01 marquiswashere

@marquiswashere maybe open another ticket to get their attention.

This seems to me like it should be easy to fix.

jchook avatar Jan 07 '22 22:01 jchook