I have code of a research project managed by datalad (which is a frontend for git and git-annex). It contains my code together with a Singularity container for reproducibility.
I installed java manually into this directory. I could run java -version initially but once I have committed my changes using git annex add <java_dir>, git add . and git commit, I cannot start java anymore. I get the following error message:
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.
How can I avoid this incompatibility between java and git-annex?
(Annex: how I installed java)
mkdir lib
cd lib
wget https://javadl.oracle.com/webapps/download/AutoDL?BundleId=246799_424b9da4b48848379167015dcc250d8d -O jre_8_341.tgz
tar -xf ./jre_8_341.tgz # creates jre1.8.0_341/
rm jre_8_341.tgz
cd jre1.8.0_341/bin
Turns out that the java binary tries to find its own path, as can be seen by calling
strace java -version:The
readlinksyscall leads into the.git/annex/objectsdirectory where git-annex saves big files. Thus,javagets the wrong answer what is its installation directory and thus fails.The solution is to
git annex unlock $JAVA_HOME/bin/java(where$JAVA_HOMEis the folder you extracted java to). The same must be done with$JAVA_HOME/lib/amd64/server/libjvm.sowhich tries the same manoever.Finally, the files must be committed in unlocked state. In effect, the files must not be symlinks into the git-annex object storage but regular files.