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

Installation on MacOS X #21

Open
jrfaller opened this issue Feb 5, 2020 · 9 comments
Open

Installation on MacOS X #21

jrfaller opened this issue Feb 5, 2020 · 9 comments

Comments

@jrfaller
Copy link

jrfaller commented Feb 5, 2020

Hi all!

I have tried to install JDime on last version of MacOS X but no success so far.

I installed libgit2 (brew install libgit2), and compiled JDime from develop (./gradlew installDist). I ran into an error:

Logging configuration file JDimeLogging.properties does not exist. Falling back to defaults.
JDime [10:41:38] GRAVE: Uncaught exception.
java.lang.LinkageError: Failed to load the git2 native library.
	at de.uni_passau.fim.seibt.LibGit2.<clinit>(LibGit2.java:105)
	at de.fosd.jdime.strategy.LinebasedStrategy.<init>(LinebasedStrategy.java:59)
	at de.fosd.jdime.config.merge.MergeContext.<init>(MergeContext.java:235)
	at de.fosd.jdime.Main.run(Main.java:137)
	at de.fosd.jdime.Main.main(Main.java:113)
Caused by: java.io.IOException: Native library (darwin/libgit2.dylib) not found in resource path ([file:/Users/falleri/work/code/jdime/build/install/JDime/lib/JDime.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/extendj.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/commons-io-2.6.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/commons-cli-1.4.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/commons-math3-3.6.1.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/commons-codec-1.11.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/xstream-1.4.10.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/gson-2.8.2.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/kvconfig-1.0.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/JNativeMerge.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/xmlpull-1.1.3.1.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/xpp3_min-1.1.4c.jar, file:/Users/falleri/work/code/jdime/build/install/JDime/lib/jna-5.2.0.jar])
	at com.sun.jna.Native.extractFromResourcePath(Native.java:1089)
	at com.sun.jna.Native.extractFromResourcePath(Native.java:1047)
	at de.uni_passau.fim.seibt.LibGit2.<clinit>(LibGit2.java:103)
	... 4 more

Any I idea what I am doing wrong?

@GSeibt
Copy link
Collaborator

GSeibt commented Feb 5, 2020

Hey,

JDime uses JNativeMerge under the hood to implement linebased merging via the libgit2 native library. This library ('libgit2.dylib' on MacOS) needs to be provided to the JVM. JNativeMerge includes the native library for Windows and Unix but we don't have any MacOS devices and therefore it doesn't for MacOS.

You need to compile or download libgit2 for MacOS and make it available to JNA (which is used by JNativeMerge for native library access). Read this tutorial (below the first code block) for how to do that.

Make sure that you use version 0.28.XX of libgit2, that's the only one we test with.

Best,
Georg

@jrfaller
Copy link
Author

jrfaller commented Feb 5, 2020

Hi Georg, and thanks a lot for your fast response.

I got it to work thank to your tutorial. I don't know why but I had no success with jna.library.path or with DYLD_LIBRARY_PATH, but I had more luck by:

  1. Modifying the path in build/install/JDime/bin/JDime shell script to include $APP_HOME/lib
  2. Add a link to libgit2.dylib in build/install/JDime/lib/darwin

@GSeibt
Copy link
Collaborator

GSeibt commented Feb 5, 2020

That's good to hear. I had a look at the JNativeMerge source code and it seems that I enforced loading the library from the classpath (instead of other locations that one might specify via the properties you mentioned). I think that is because this way it's a lot harder to use an invalid version of the library.

Your modifications will only survive until the next time you rebuild JDime. Here is how to include an arbitrary library in the .jar file generated for JNativeMerge (and thereby the classpath).

  • Clone JNativeMerge (under exactly this name) as a sibling directory of the JDime directory
  • Set JNM_MAVEN=false in JDime/gradle.properties
  • Set jnativemerge.libgit2.path=<Absolute Path to Library> in JNativeMerge/gradle.properties
  • Run ./gradlew test in the JNativeMerge directory to test whether the library was correctly included
  • Run ./gradlew installDist in the JDime directory to build JDime

This should work with the develop branch of JDime.

@jrfaller
Copy link
Author

jrfaller commented Feb 7, 2020

Hi Georg and thanks for the tip!

Quick question, wouldn't it be possible for JNativeMerge to try to load first the library from the resource classpath and only if it does not found it, try loading it from the system path (that implies removing the System.setProperty("jna.nosys", "true");)? This way it would be the best of both worlds. I have tried to look for examples, I am not sure it can be done though.

@GSeibt
Copy link
Collaborator

GSeibt commented Feb 7, 2020

Hey,

please apply the following patch to your build.gradle:

diff --git a/build.gradle b/build.gradle
index da729b05..a0165214 100644
--- a/build.gradle
+++ b/build.gradle
@@ -87,7 +87,7 @@ dependencies {
     implementation 'de.uni-passau.fim.seibt:kvconfig:1.0'
 
     if (project.ext.JNM_MAVEN.toBoolean()) {
-        implementation 'de.uni_passau.fim.seibt:jnativemerge:0.28.1_3'
+        implementation 'de.uni_passau.fim.seibt:jnativemerge-snapshot:95708997'
     } else {
         implementation project(':JNativeMerge')
     }

Also set JNM_MAVEN=false and rebuild JDime. You should be able to use the JVM property jnativemerge.syslib_fallback=true to have JNativeMerge check the other JNA locations as a fallback. You can pass JVM Options through the JDime start script (that is generated by Gradle) using the environment variable JAVA_OPTS.

Best,
Georg

@jrfaller
Copy link
Author

Hi!

Thanks a lot, it's awesome!

Unfortunately, but I do not get it to work. When you mean rebuilt you mean gradle build followed by gradle installDist on the develop branch right? Maybe I should not set JNM_MAVEN to false, since I need to download the dependency from maven according to your patch?

@jrfaller
Copy link
Author

(for info, I set JAVA_OPTS this way : set JAVA_OPTS "-Djnativemerge.syslib_fallback=true -Djna.library.path=/usr/local/lib")

@GSeibt
Copy link
Collaborator

GSeibt commented Feb 11, 2020

Oh sorry, I meant JNM_MAVEN=true. That will cause the buildscript to download JNativeMerge as a Maven package instead of including the Gradle build directly. The snapshot version of JNativeMerge that I published should have the functionality you suggested.

Rebuilding would be ./gradlew clean installDist. The clean task should not be required even...

@jrfaller
Copy link
Author

OK still no luck with JNM_MAVEN=true. I have looked in the build/install/JDime/lib folder and I have the correct library jnativemerge-snapshot-95708997.jar. Maybe there is a typo on the name of the property?

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

2 participants