Skip to content
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

node-gyp rebuild fails. fatal error: 'jni_md.h' file not found on OSX 10.11.5 #343

Open
gnizhak opened this issue Jul 28, 2016 · 6 comments

Comments

@gnizhak
Copy link

gnizhak commented Jul 28, 2016

We use node-tika for our project and it's only dependency is node-java. Last week npm install started failing to an error during node-gyp rebuild

> [email protected] install /Users/gnizhak/redacted/node_modules/java
> node-gyp rebuild

  CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
In file included from ../src/java.cpp:1:
In file included from ../src/java.h:7:
/Users/gnizhak/.jenv/versions/1.7/include/jni.h:45:10: fatal error: 'jni_md.h' file not found
#include "jni_md.h"

1 error generated.
make: *** [Release/obj.target/nodejavabridge_bindings/src/java.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.5.0
gyp ERR! command "/usr/local/Cellar/node/5.7.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/gnizhak/redacted/node_modules/java

gyp ERR! node -v v5.7.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1

as you can see from the error message I use jenv to manage my java version but the issue appears on both java 1.7 and 1.8. My JAVA_HOME is thus set /Users/gnizhak/.jenv/versions/1.7 or 1.8
Both JDK installations are Oracle Java and I do not have java 1.6 installed.

xcode-select version 2343 and xcode version 7.3.1 (so gcc says Apple LLVM 7.3.0)

I'm not really in on how the java includes folder is setup on Oracle Java I tried to do some digging and found that
/Library/Java/JavaVirtualMachines/{jdk_version}/Contents/Home/include
does not contain jni_md.h directly but instead has a subfolder
/Library/Java/JavaVirtualMachines/{jdk_version}/Contents/Home/include/darwin where the jni_md.h header file resides.

This issue did not appear in May, but I was away from the project most of June and July so I cannot tell which update may have caused this issue.

I checked out the Info.plist capabilities section referenced in #90 (comment) and found that 1.8 already had the capability there and adding that to 1.7 did not resolve the issue.

My colleague with OSX 10.10.5 with xcode-select 2339/xcode 7.2.1 had no such issue.

@tandrewnichols
Copy link

I'm having the same issue. Also using jenv. Is it possible it's a problem with jenv?

@owendall
Copy link

owendall commented Apr 5, 2017

I am having the same issue when I tried to use the "jabba" java environment manager. Any updates on this issue?

@cksachdev
Copy link

@gnizhak Have you figured out a solution for this? I have the same issue, managing java versions using jabba and when installing it fails.
cc: @owendall @tandrewnichols

@gnizhak
Copy link
Author

gnizhak commented Jan 8, 2019

I ended up giving up on jenv and installing different sdks independently. So it has to be the way the jenv/jabba handles the paths on the dependencies.

@doctorpangloss
Copy link

This is an issue I think for all conformant non-Oracle JDKs at least since 11 on macOS, because jni_md.h is located in /include/darwin

@cdolek
Copy link

cdolek commented Aug 12, 2020

Mac OS Catalina 10.15.16, using jenv.

I noticed that $JAVA_HOME was not set. Disabling and enabling jenv plugins fixed this.

Per @doctorpangloss's comment copied the file to parent dir:

cp /Users/_username_/.jenv/versions/openjdk64-1.8.0.265/include/darwin/jni_md.h ../

npm install java - voila!

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

No branches or pull requests

6 participants