File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ import org.apache.logging.log4j.core.config.Configurator
44
44
45
45
const val TOOL_NAME = " ort"
46
46
47
+ /* *
48
+ * The name of the environment variable to customize the ORT user home.
49
+ */
50
+ const val ORT_USER_HOME_ENV = " ORT_USER_HOME"
51
+
47
52
/* *
48
53
* The main entry point of the application.
49
54
*/
@@ -96,9 +101,30 @@ object OrtMain : CommandWithHelp() {
96
101
*/
97
102
@JvmStatic
98
103
fun main (args : Array <String >) {
104
+ fixupUserHomeProperty()
99
105
exitProcess(run (args))
100
106
}
101
107
108
+ /* *
109
+ * Check if the "user.home" property is set to a sane value and otherwise set it to the value of the ORT_USER_HOME
110
+ * environment variable, if set, or to the value of an (OS-specific) environment variable for the user home
111
+ * directory. This works around the issue that esp. in certain Docker scenarios "user.home" is set to "?", see
112
+ * https://bugs.openjdk.java.net/browse/JDK-8193433 for some background information.
113
+ */
114
+ fun fixupUserHomeProperty () {
115
+ val userHome = System .getProperty(" user.home" )
116
+ val checkedUserHome = sequenceOf(
117
+ userHome,
118
+ System .getenv(ORT_USER_HOME_ENV ),
119
+ System .getenv(" HOME" ),
120
+ System .getenv(" USERPROFILE" )
121
+ ).first {
122
+ it != null && it.isNotBlank() && it != " ?"
123
+ }
124
+
125
+ if (checkedUserHome != userHome) System .setProperty(" user.home" , checkedUserHome)
126
+ }
127
+
102
128
/* *
103
129
* Run the ORT CLI with the provided [args] and return the exit code of [CommandWithHelp.run].
104
130
*/
You can’t perform that action at this time.
0 commit comments