javagitjgit

Jgit throws java.io.IOException: Creating directories for /.config/jgit failed


Recently upgraded Jgit to 5.10.0.202012080955-r. After this, we are getting IOException after clone of a bare git repository. It doesn't seem to cause any visible functional impact so far, but its a cause of concern. This issue is seen only in Kubernetes deployment not with Junit tests. Is it a known issue ? If yes, any workarounds or anything missing here ?

Thanks.

[36morg.eclipse.jgit.util.FS                [0;39m [2m:[0;39m Cannot save config file 'FileBasedConfig[/.config/jgit/config]'

java.io.IOException: Creating directories for /.config/jgit failed
    at org.eclipse.jgit.util.FileUtils.mkdirs(FileUtils.java:411) ~[org.eclipse.jgit-5.10.0.202012080955-r.jar!/:5.10.0.202012080955-r]
    at org.eclipse.jgit.internal.storage.file.LockFile.lock(LockFile.java:130) ~[org.eclipse.jgit-5.10.0.202012080955-r.jar!/:5.10.0.202012080955-r]
    at org.eclipse.jgit.storage.file.FileBasedConfig.save(FileBasedConfig.java:219) ~[org.eclipse.jgit-5.10.0.202012080955-r.jar!/:5.10.0.202012080955-r]
    at org.eclipse.jgit.util.FS$FileStoreAttributes.saveToConfig(FS.java:735) ~[org.eclipse.jgit-5.10.0.202012080955-r.jar!/:5.10.0.202012080955-r]
    at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$4(FS.java:424) ~[org.eclipse.jgit-5.10.0.202012080955-r.jar!/:5.10.0.202012080955-r]
    at org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$1660/0x00000000f4008230.run(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at java.base/java.lang.Thread.run(Thread.java:836) ~[na:na]

Solution

  • In this particular case Jgit is trying to create a configuration file at a path based on XDG_CONFIG_HOME.

    If XDG_CONFIG_HOME is not set, it will be having default value $HOME/.config. This particular path is not accessible in my Kubernetes environment.

    Changed XDG_CONFIG_HOME to point to appropriate path. Thus Jgit will be able to create configuration file.