node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

npm ERR! gyp: name 'openssl_fips' is not defined

Open 2812848295 opened this issue 3 years ago • 11 comments

Solution: https://github.com/nodejs/node-gyp/issues/2673#issuecomment-1196931379

• electron-builder version=22.14.13 • rebuilding native dependencies [email protected], [email protected] platform=darwin arch=arm64 ⨯ cannot execute cause=exit status 1 errorOut=npm ERR! code 1 npm ERR! path /Users/wks/Desktop/electron/terrasync/node_modules/ffi-napi npm ERR! command failed npm ERR! command sh -c node-gyp-build npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | darwin | arm64 npm ERR! gyp info find Python using Python version 3.8.9 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3" npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/Users/wks/Desktop/electron/terrasync/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/wks/Desktop/electron/terrasync/node_modules/ffi-napi/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/wks/Desktop/electron/terrasync/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/wks/.electron-gyp/11.5.0/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/wks/.electron-gyp/11.5.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/wks/Desktop/electron/terrasync/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/wks/.electron-gyp/11.5.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/wks/Desktop/electron/terrasync/node_modules/ffi-napi', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in ../node-addon-api/node_api.gyp while loading dependencies of binding.gyp while trying to load binding.gyp npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: gyp failed with exit code: 1 npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/Users/wks/Desktop/electron/terrasync/node_modules/node-gyp/lib/configure.js:261:16) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:520:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) npm ERR! gyp ERR! System Darwin 21.5.0 npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/wks/Desktop/electron/terrasync/node_modules/.bin/node-gyp" "rebuild" npm ERR! gyp ERR! cwd /Users/wks/Desktop/electron/terrasync/node_modules/ffi-napi npm ERR! gyp ERR! node -v v16.14.0 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/wks/.npm/_logs/2022-06-01T07_14_18_457Z-debug-0.log

                command=/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js rebuild [email protected] [email protected]
                workingDir=

┌────────────────────────────────────────────────────────┐ │ electron-builder update check failed │ │ Try running with sudo or get access │ │ to the local update config store via │ │ sudo chown -R $USER:$(id -gn $USER) /Users/wks/.config │ └────────────────────────────────────────────────────────┘ npm ERR! code 1 npm ERR! path /Users/wks/Desktop/electron/terrasync npm ERR! command failed npm ERR! command sh -c electron-builder install-app-deps

npm ERR! A complete log of this run can be found in: npm ERR! /Users/wks/.npm/_logs/2022-06-01T07_14_16_686Z-debug-0.log

2812848295 avatar Jun 01 '22 07:06 2812848295

根据找到的资料在binding.gyp也添加了 ‘variables’:{'openssl_fips':0}

According to the information found, 'variables':{'openssl_fips':0} is also added to binding.gyp

2812848295 avatar Jun 01 '22 07:06 2812848295

https://github.com/nodejs/node-gyp/search?q=openssl_fips&type=issues

cclauss avatar Jun 01 '22 07:06 cclauss

@cclauss 刚刚发现23天前我也像你们提过这个问题,但是貌似后续我解决了 ,当时是在windows上面。现在换了macos

Just found out that I also mentioned this problem like you 23 days ago, but it seems that I solved it later, which was on windows at that time. Switch to macOS now

2812848295 avatar Jun 01 '22 07:06 2812848295

node -v 16.14.0

2812848295 avatar Jun 01 '22 07:06 2812848295

之前通过很多尝试把问题修复了,但是我把node_module删除了 现在windows 也面临这个问题

I fixed the problem through many attempts before, but I deleted node_module and now windows is also facing this problem

2812848295 avatar Jun 01 '22 08:06 2812848295

I had the same issue with Node14. The version below node17 does not seem to match [email protected], downgrade node-gyp to version "v8.3.0", the issue is solved for me.

zhong-fei avatar Jun 24 '22 07:06 zhong-fei

Looking at https://github.com/nodejs/node-gyp/search?q=openssl_fips

  • https://github.com/nodejs/node-gyp/issues/2534#issuecomment-954978227

In binding.gyp please try to add a line to

'variables' : {
    'openssl_fips': '',
}

cclauss avatar Jun 24 '22 08:06 cclauss

gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1

cqh52306 avatar Jul 18 '22 09:07 cqh52306

I did not want to edit the binding.gyp file of a module that I was using. So I solved this problem by passing "--openssl_fips=''" into the script I want to use, like npm install --openssl_fips=''

arjunfulp avatar Jul 27 '22 15:07 arjunfulp

Does this solution solve all name 'openssl_fips' is not defined issues?

cclauss avatar Jul 27 '22 17:07 cclauss

Does this solution solve all name 'openssl_fips' is not defined issues?

For my case yes. Had to make this change after updating node and npm to latest.

arjunfulp avatar Jul 27 '22 17:07 arjunfulp

When using yarn it seems the --openssl_fips='' passed to yarn does not make a difference. If the issue happens in a dependency, editing binding.gyp in the node_modules/ directory gets reverted automatically. I ended up with a workaround that edits gyp's source code directly:

The gyp source code location is printed in the error message:

gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/quark/.config/yarn/global/node_modules/node-gyp/lib/configure.js:285:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

gyp seems to evaluate the binding.gyp as a Python script, I changed the builtin variables to evaluate the script:

diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py
index 354958b..bb982eb 100644
--- a/gyp/pylib/gyp/input.py
+++ b/gyp/pylib/gyp/input.py
@@ -1190,7 +1190,7 @@ def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, buil
         else:
             ast_code = compile(cond_expr_expanded, "<string>", "eval")
             cached_conditions_asts[cond_expr_expanded] = ast_code
-        env = {"__builtins__": {}, "v": StrictVersion}
+        env = {"__builtins__": {"openssl_fips": ""}, "v": StrictVersion}
         if eval(ast_code, env, variables):
             return true_dict
         return false_dict

The input.py is located in the node-gyp directory printed in the above error message, for example:

  • /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py
  • ~/.config/yarn/global/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py

quark-zju avatar Sep 07 '22 16:09 quark-zju

Here facing same issue:

yarn v1.22.19 node lts/gallium => 16.17.0 MacOS Monterey => 12.5.1

Workaround above https://github.com/nodejs/node-gyp/issues/2673#issuecomment-1196931379 did work fine

In addition I run both, yarn install and npm install.

yarn install 
npm install --openssl_fips=''

angelfraga avatar Sep 20 '22 13:09 angelfraga

@2812848295 Can this issue be closed?

cclauss avatar Sep 20 '22 13:09 cclauss

env = {"__builtins__": {"openssl_fips": ""}, "v": StrictVersion}

This worked for me. Thank you

arenn23 avatar Sep 23 '22 18:09 arenn23

Hi. On Linux, node 18.7.0, building electron 20.0.3 for Element Matrix, none of the suggested solutions work.

squid-f avatar Sep 26 '22 17:09 squid-f

What might be the solution for defining openssl_fips in gyp when not running npm install? Is there a node script.js equivalent? Passing in --openssl_fips='' does nothing (nor did I expect it to).

I can add "openssl_fips" : "" to the variables section of binding.gyp, but the project I'm working with has sub dependencies with lots of .gyp files that I cannot edit. Nor does that seem like the ideal solution. Changing it in the top-level binding.gyp does not cause the variable to be "passed down"

Is there another workaround?

dhritzkiv avatar Oct 07 '22 21:10 dhritzkiv

Same issue here - adding yarn --openssl_fips='' does not work for me.

bensig avatar Oct 11 '22 18:10 bensig

With Node 14 on Ubuntu 22.10, I solved this by downgrading npm to version 6 (npm install -g npm@6). Noticed the issue started as soon as I updated npm to version 9. The project was using yarn.

radu-b avatar Nov 24 '22 16:11 radu-b

Had an issue on my Mac M1 with npm 8 (8.12.1) and node 14 and I managed to solved this by downgrading to npm 6 (latest-6).

LaurentGENTY avatar Dec 12 '22 10:12 LaurentGENTY

I solved this downgrading node-gyp to version 8.4.1 ( yarn add [email protected] -D) which used in electron version 9 native build scenario.

akiratfli avatar Dec 28 '22 07:12 akiratfli

https://releases.electronjs.org/releases/stable says v22

cclauss avatar Dec 28 '22 08:12 cclauss

For me, where the issue came from an electron project, upgrading electron and electron-builder to latest (23.1.4 and 23.6.0 respectively) solved the issue.

lukasbach avatar Mar 21 '23 11:03 lukasbach

--openssl_fips=''

For my case, it is only failed at npm start, so I run this to overcome: npm start --openssl_fips=''

whatisor avatar Jul 13 '23 18:07 whatisor

@arjunfulp You can avoid passing the flag in the npm install command by adding openssl_fips to the npm configuration:

npm config set openssl_fips ''

KernelPanic92 avatar Oct 19 '23 10:10 KernelPanic92

@KernelPanic92 Not with up-to-date versions of npm. % npm config list # What are my current settings? % npm config list -l # What are all valid settings?

openssl_fips was removed from that list along with many other settings.

cclauss avatar Oct 19 '23 12:10 cclauss