Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

gyp: name 'openssl_fips' is not defined - node-gyp error #163

Open
phhoef opened this issue Mar 2, 2022 · 12 comments
Open

gyp: name 'openssl_fips' is not defined - node-gyp error #163

phhoef opened this issue Mar 2, 2022 · 12 comments

Comments

@phhoef
Copy link

phhoef commented Mar 2, 2022

I am trying to re-compile usb-detection on an Apple M1 Mac.
Unfortunately, I do get a error

 ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path /Users/me/Documents/Client/node_modules/usb-detection
    npm ERR! command failed
    npm ERR! command sh -c prebuild-install || node-gyp rebuild
    npm ERR! prebuild-install WARN install No prebuilt binaries found (target=11.5.0 runtime=electron arch=arm64 libc= platform=darwin)
    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.9.10 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
    npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/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/me/Documents/Client/node_modules/usb-detection/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/me/.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/me/.electron-gyp/11.5.0',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/me/.electron-gyp/11.5.0/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/me/Documents/Client/node_modules/usb-detection',
    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 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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    npm ERR! gyp ERR! System Darwin 21.3.0
    npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/17.6.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    npm ERR! gyp ERR! cwd /Users/me/Documents/Client/node_modules/usb-detection
    npm ERR! gyp ERR! node -v v17.6.0
    npm ERR! gyp ERR! node-gyp -v v8.4.1
    npm ERR! gyp ERR! not ok

Anybody can think how to workaround this?

@MadLittleMods
Copy link
Owner

Related to #141

@phhoef
Copy link
Author

phhoef commented Mar 3, 2022

Can you think of any workaround?
The error above is thrown, when running electron-builder install-app-deps. When running with --arch x64 flag it is working. The app will also work, when packaged as I am also packaging for x64. But in dev mode, it even won't start as the native dependency is built for the wrong architecture.
Is there a way to start start in dev mode with x64?

@MadLittleMods
Copy link
Owner

I don't know @phhoef 🙇

@donovanhiland
Copy link

FWIW I worked through a similar issue while setting up builds in CI for windows. After googling around I found that the specific error you mentioned relating to openssl_fips has something to do with Node 17 not including some configuration by default any more. Downgrading to 16 worked as a temporary fix:

nodejs/node-gyp#2534
marktext/marktext#2812

@MadLittleMods
Copy link
Owner

@todbot what node-gyp PR fixed this?

It looks like node-gyp@^8.4.0 includes this potential fix nodejs/node-gyp#2497 mentioned in nodejs/node-gyp#2534 (comment)

But I can see that @phhoef was reproducing with [email protected] which came after.


In terms of workarounds I see,

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=''

-- nodejs/node-gyp#2673 (comment)

Or modifying binding.gyp to make the same change.

@lukedar
Copy link

lukedar commented Mar 3, 2023

@MadLittleMods @phhoef seem like this is not exclusively an M1 issue. I get the same error on intel core i5 running node16`

errorOut=prebuild-install warn This package does not support N-API version 4.2.12
    prebuild-install warn install No prebuilt binaries found (target=4.2.12 runtime=napi arch=x64 libc= platform=darwin)
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
    gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/Users/lukedarham/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/Users/lukedarham/Documents/apps/idoru-desktop/node_modules/drivelist/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/Users/lukedarham/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/Users/lukedarham/.electron-gyp/4.2.12/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/Users/lukedarham/.electron-gyp/4.2.12',
    gyp info spawn args   '-Dnode_gyp_dir=/Users/lukedarham/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/Users/lukedarham/.electron-gyp/4.2.12/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/Users/lukedarham/Documents/apps/idoru-desktop/node_modules/drivelist',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    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
    gyp ERR! stack     at ChildProcess.onCpExit (/Users/lukedarham/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:284:16)
    gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
    gyp ERR! System Darwin 21.6.0
    gyp ERR! command "/Users/lukedarham/.nvm/versions/node/v16.19.1/bin/node" "/Users/lukedarham/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /Users/lukedarham/Documents/apps/idoru-desktop/node_modules/drivelist
    gyp ERR! node -v v16.19.1
    gyp ERR! node-gyp -v v9.1.0
    gyp ERR! not ok
error Command failed with exit code 1.`

Do you guys find a fix for this? Im really stuck and not sure where to go from here.

@phhoef
Copy link
Author

phhoef commented Mar 3, 2023

No, I didn't found a solution for that problem.
My workaround is to remove usb-detection as dependency. I am using serialport for communication. I build a timer, that polls every few seconds for new devices through the serialport lib.

@lukedar
Copy link

lukedar commented Mar 3, 2023 via email

@phhoef
Copy link
Author

phhoef commented Mar 3, 2023

The code is part of a bigger application, but I am trying to post the relevant code snips.
I am using redux as state container.

I've also a button where the user can manually trigger a refresh of the serial port.
So, the redux part was already in place, I've just added the timer as workaround.
redux action:

export const getSerialports = () => async (dispatch) =>
{
  const ports = await serialport.list();
  dispatch({
    type: SerialportTypeKeys.GET_SERIAL_PORTS,
    ports
  });
}

redux reducer:
The reducer also preselects the first found serial port, if the user hasn't select one...

  switch (action.type) {
    case SerialportTypeKeys.GET_SERIAL_PORTS:
      if (action.ports.length > 0) {
        const selectedPort =
          state.selectedPort === null
            ? action.ports[0]
            : action.ports.find((p) => p.path === state.selectedPort.path);
        return { ...state, ports: action.ports, selectedPort };
      } else return { ...state, ports: action.ports, selectedPort: null };
}

In my index.tsx I am calling the timer:

const store = configureStore();
const boundActions = bindActionCreators({ getSerialports }, store.dispatch);

let lastPorts = [];
const checkSerialPorts = async () => {
  const ports = await SerialPort.list();
  if (!equalPorts(lastPorts, ports)) boundActions.getSerialports();

  lastPorts = ports;
  setTimeout(checkSerialPorts, 2000);
};
checkSerialPorts();

I need to make this binding to the store, as I want to call the redux action.
You probably can reduce the complexity and only use the checkSerialPorts() method.

I also needed a proper equals check to determine if an update of the available ports is necessary. Otherwise I would flood my redux store with unnecessary changes ...

export const equalPorts = (a: IPort[], b: IPort[]) => {
  return (
    Array.isArray(a) &&
    Array.isArray(b) &&
    a.length === b.length &&
    a.every((val, index) => val.path === b[index].path)
  );
};

Hope this helps 🙂

@lukedar
Copy link

lukedar commented Mar 3, 2023 via email

@MadLittleMods MadLittleMods changed the title Apple M1 'openssl_fips' is not defined gyp: name 'openssl_fips' is not defined - node-gyp error Mar 3, 2023
@lukedar
Copy link

lukedar commented Mar 4, 2023

Unfortunately after trying the serialport module I get the following error.

dyld[50034]: missing symbol called
phhoef did you experience this also?

@phhoef
Copy link
Author

phhoef commented Mar 4, 2023

Sony, not as far as I remember.
i typically try to use the pre-builds if possible.
probably asking the serialport guys, is a good idea

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants