facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.81k stars 635 forks source link

[Bug] Hydra fails to build because of wrong java version? #2897

Closed Revist closed 6 months ago

Revist commented 6 months ago

Hi everybody,

πŸ› Bug

Description

Basically cloning current hydra repository and running pip install .

results in the following error.

Building wheels for collected packages: hydra-core
  Building wheel for hydra-core (pyproject.toml) ... error
  error: subprocess-exited-with-error

  Γ— Building wheel for hydra-core (pyproject.toml) did not run successfully.
  β”‚ exit code: 1
  ╰─> [83 lines of output]
      <string>:8: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      /tmp/pip-build-env-w7mvk_t2/overlay/bin:/tmp/pip-build-env-w7mvk_t2/normal/bin:./java/jdk-17.0.11/bin:java/jdk-21.0.3/bin:java/jdk-21.0.3/bin:java/jdk-21.0.3/bin:java/jdk-21_linux-x64_bin/bin:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/etc:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/linux2.6-glibc2.3-x86_64/bin:/opt/share/exec:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/etc:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/bin:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/etc:/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/linux2.6-glibc2.3-x86_64/bin:/opt/share/exec:/u/xxx/.vscode-server/cli/servers/Stable-5c3e652f63e798a5ac2f31ffd0d863669328dc4c/server/bin/remote-cli:/xxx/anaconda3/bin:/xxx/anaconda3/condabin:/u/xxx/.local/bin:/u/xxx/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/linux2.6-glibc2.3-x86_64/bin:/opt/share/exec:/usr/share/Modules/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/bin:/opt/ibm/lsfsuite/ext/ppm/10.2/linux2.6-glibc2.3-x86_64/bin:/opt/share/exec:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/lpp/mmfs/bin:/bin:/usr/bin:/bin:/usr/bin:/bin:/usr/bin:/bin:/usr/bin
      running bdist_wheel
      running build
      running build_py
      running clean
      Generating parsers with antlr4
      running antlr
      Generating parser for Python3: ['java', '-jar', 'xxx/hydra/build_helpers/bin/antlr-4.11.1-complete.jar', '-Dlanguage=Python3', '-o', '/xxx/hydra/hydra/grammar/gen/', '-Xexact-output-dir', '-visitor', 'xxx/hydra/hydra/grammar/OverrideLexer.g4']
      Error: A JNI error has occurred, please check your installation and try again
      Exception in thread "main" java.lang.UnsupportedClassVersionError: org/antlr/v4/Tool has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:621)
      Traceback (most recent call last):
        File "xxx/anaconda3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "xxx/anaconda3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "xxx/anaconda3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 410, in build_wheel
          return self._build_with_temp_dir(
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 29, in <module>
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 104, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 967, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-w7mvk_t2/normal/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 368, in run
          self.run_command("build")
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 967, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 967, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "xxx/hydra/build_helpers/build_helpers.py", line 154, in run
          run_antlr(self)
        File "xxx/hydra/build_helpers/build_helpers.py", line 139, in run_antlr
          cmd.run_command("antlr")
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 967, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-w7mvk_t2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "xxx/hydra/build_helpers/build_helpers.py", line 201, in run
          subprocess.check_call(command)
        File "xxx/anaconda3/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['java', '-jar', 'xxx/hydra/build_helpers/bin/antlr-4.11.1-complete.jar', '-Dlanguage=Python3', '-o', 'xxx/hydra/hydra/grammar/gen/', '-Xexact-output-dir', '-visitor', '/xxx/hydra/hydra/grammar/OverrideLexer.g4']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for hydra-core
Failed to build hydra-core
ERROR: Could not build wheels for hydra-core, which is required to install pyproject.toml-based projects

I downloaded new java from https://www.oracle.com/java/technologies/downloads/#java21 and added it to path, but the error still persists. What is interesting is that running:

pip install -e .

installs everything correctly.

Checklist

To reproduce

Minimal Code/Config snippet to reproduce git clone git@github.com:facebookresearch/hydra.git cd hydra pip install .

Revist commented 6 months ago

Very sad mistake of using relative path when setting JAVA_HOME.