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

rPackages.rJava does not build with Azul JDK #109419

Closed
alexvorobiev opened this issue Jan 15, 2021 · 6 comments
Closed

rPackages.rJava does not build with Azul JDK #109419

alexvorobiev opened this issue Jan 15, 2021 · 6 comments
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: java Including JDK, tooling, other languages, other VMs

Comments

@alexvorobiev
Copy link
Contributor

Describe the bug
rPackages.rJava won't install if the JDK is Azul.

To Reproduce
~/.config/nixpkgs/overlays/java.nix:

self: super:
with super; {
  jdk8 = zulu8;
  jdk = zulu8;
}
$ nix-shell -p rPackages.rJava
.....
checking Java support in R... present:
interpreter : '/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/jre/bin/java'
archiver    : '/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/bin/jar'
compiler    : '/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/bin/javac'
header prep.: '/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/bin/javah'
cpp flags   : '-I/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/include/'
java libs   : '-L/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether -Xrs will be used... yes
checking whether JVM will be loaded dynamically... no
checking whether JNI programs can be compiled... configure: error: Cannot compile a simple JNI program. See config.log for details.

Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.

ERROR: configuration failed for package 'rJava'
* removing '/nix/store/d8r376x3dhgdpzpjs1c4lbmyi41z7d0w-r-rJava-0.9-13/library/rJava'
builder for '/nix/store/7g0i92kkdian0jsh9b00w4gp5whss093-r-rJava-0.9-13.drv' failed with exit code 1
error: build of '/nix/store/7g0i92kkdian0jsh9b00w4gp5whss093-r-rJava-0.9-13.drv' failed

Notify maintainers
@peti @michelk @mimame @fpletz

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 3.10.0-1160.11.1.el7.x86_64, Red Hat Enterprise Linux Server, 7.9 (Maipo)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.10`
 - channels(root): `"nixpkgs-21.03pre261451.f53c431645d"`
 - nixpkgs: `/root/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
 - rPackages.rJava
# a list of nixos modules affected by the problem
module:
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-shell-environment-to-debug-a-build-of-an-r-package/11010/1

@alexvorobiev
Copy link
Contributor Author

alexvorobiev commented Jan 19, 2021

Running nix-shell --pure -p rPackages.rJava --keep-failed preserved the config.log so it is clear what the issue is:

In file included from conftest.c:30:                                                                                                                                             
/nix/store/3xlg2rn1mkpypxd2xvz26xrlgfrbrmnr-zulu-8.48.0.53/include/jni.h:45:10: fatal error: jni_md.h: No such file or directory                                                 
   45 | #include "jni_md.h"                                                                                                                                                      
      |          ^~~~~~~~~~                                                                                                                                                      
compilation terminated.    

which is (partly) what #106716 is about.

So as a workaround I am using this overlay where I added the symlinks to the installPhase from https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/zulu/8.nix:

self: super:
with super; {
  zulu8 = super.zulu8.overrideAttrs (attrs: {

    installPhase = ''
      mkdir -p $out
      cp -r ./* "$out/"

      jrePath="$out/jre"

      rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/jli
      rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/server
      rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/xawt
      rpath=$rpath''${rpath:+:}$jrePath/lib/amd64

      # set all the dynamic linkers
      find $out -type f -perm -0100 \
        -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
        --set-rpath "$rpath" {} \;

      find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;

      mkdir -p $out/nix-support
      printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs

      # jni.h expects jni_md.h to be in the header search path.
      ln -s $out/include/linux/*_md.h $out/include/

      # Set JAVA_HOME automatically.
      cat <<EOF >> $out/nix-support/setup-hook
      if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
      EOF
    '';
  });
}

@taku0
Copy link
Contributor

taku0 commented Jan 23, 2021

I made a PR to fix this: #110567. It is a draft because it depends on another PR #107784.

@taku0
Copy link
Contributor

taku0 commented Feb 13, 2021

#110567 is now ready to merge. Could you test/review it?

@roberth roberth added the 6.topic: java Including JDK, tooling, other languages, other VMs label Jun 21, 2021
@alexvorobiev
Copy link
Contributor Author

The PR looks good to me.

@stale
Copy link

stale bot commented Jan 9, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: java Including JDK, tooling, other languages, other VMs
Projects
None yet
Development

No branches or pull requests

4 participants