Skip to content

Commit 298a964

Browse files
committed
fix(cli): Do not output ORT_* environment variables unless set
The previous code did always output values for `ORT_CONFIG_DIR` and `ORT_DATA_DIR` even if these variables were not set, in which case their internal defaults were shown. This is confusion when dealing with reports from users, as it is unclear whether these variables were actually set. Change the code to only show values for these variables if they really were set, aligning with the behavior for third-party variables shown. While at it, also show `ORT_TOOLS_DIR` if set. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 15f2b4f commit 298a964

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

cli/src/main/kotlin/OrtMain.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ import org.ossreviewtoolkit.utils.common.expandTilde
5757
import org.ossreviewtoolkit.utils.common.mebibytes
5858
import org.ossreviewtoolkit.utils.common.replaceCredentialsInUri
5959
import org.ossreviewtoolkit.utils.ort.Environment
60-
import org.ossreviewtoolkit.utils.ort.ORT_CONFIG_DIR_ENV_NAME
6160
import org.ossreviewtoolkit.utils.ort.ORT_CONFIG_FILENAME
62-
import org.ossreviewtoolkit.utils.ort.ORT_DATA_DIR_ENV_NAME
6361
import org.ossreviewtoolkit.utils.ort.ORT_NAME
6462
import org.ossreviewtoolkit.utils.ort.ortConfigDirectory
65-
import org.ossreviewtoolkit.utils.ort.ortDataDirectory
6663
import org.ossreviewtoolkit.utils.ort.printStackTrace
6764

6865
import org.slf4j.LoggerFactory
@@ -207,11 +204,7 @@ class OrtMain : CliktCommand(ORT_NAME) {
207204
row {
208205
val content = mutableListOf("Environment variables:")
209206

210-
listOf(
211-
ORT_CONFIG_DIR_ENV_NAME to ortConfigDirectory.path,
212-
ORT_DATA_DIR_ENV_NAME to ortDataDirectory.path,
213-
*env.variables.toList().toTypedArray()
214-
).mapTo(content) { (key, value) ->
207+
env.variables.mapTo(content) { (key, value) ->
215208
val safeValue = value.replaceCredentialsInUri(MaskedString.DEFAULT_MASK)
216209
"${Theme.Default.info(key)} = ${Theme.Default.warning(safeValue)}"
217210
}

utils/ort/src/main/kotlin/Environment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ data class Environment(
9999
val ORT_USER_AGENT = "$ORT_NAME/$ORT_VERSION"
100100

101101
private val RELEVANT_VARIABLES = listOf(
102+
// ORT variables.
103+
ORT_DATA_DIR_ENV_NAME,
104+
ORT_CONFIG_DIR_ENV_NAME,
105+
ORT_TOOLS_DIR_ENV_NAME,
102106
// Windows variables.
103107
"USERPROFILE",
104108
"OS",

0 commit comments

Comments
 (0)