Skip to content

Commit 0931d7a

Browse files
committed
Only convert known env vars to WSL paths.
1 parent b45b47f commit 0931d7a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/org/elixir_lang/sdk/wsl/WslCompatService.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlin.io.path.absolutePathString
1111

1212
const val MODERN_WSL_PREFIX = "\\\\wsl.localhost\\"
1313
const val LEGACY_WSL_PREFIX = "\\\\wsl$\\"
14-
14+
private val envVarsToConvert = setOf("MIX_HOME", "MIX_ARCHIVES")
1515
/**
1616
* Service wrapper for WSL (Windows Subsystem for Linux Integration).
1717
*
@@ -149,7 +149,11 @@ interface WslCompatService {
149149

150150
// Modify ProcessBuilder environment in place
151151
val env = processBuilder.environment()
152-
env.replaceAll { _, value -> convertWslPathsInString(value, distribution) }
152+
for (key in envVarsToConvert) {
153+
env[key]?.let { value ->
154+
env[key] = convertWslPathsInString(value, distribution)
155+
}
156+
}
153157
}
154158

155159
/**

tests/org/elixir_lang/sdk/wsl/WslArgumentConversionTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,16 @@ public void testConvertWindowsDrivePathsInEnvironment() {
310310

311311
commandLine.setExePath("\\\\wsl$\\Ubuntu\\usr\\bin\\elixir");
312312
commandLine.setWorkDirectory(WSL_WORK_DIR);
313-
commandLine.getEnvironment().put("MYPATH", "C:/Users/user/bin");
314-
commandLine.getEnvironment().put("DATADIR", "D:\\data\\files");
313+
commandLine.getEnvironment().put("PATH", "/home/user/.local/share/mise/installs/elixir/1.17.3/bin:/home/user/.local/share/mise/installs/elixir/1.17.3/.mix/escripts");
314+
commandLine.getEnvironment().put("MIX_HOME", "C:/Users/user/.mix");
315+
commandLine.getEnvironment().put("MIX_ARCHIVES", "D:\\data\\mix_archives");
315316

316317
ProcessBuilder processBuilder = toProcessBuilder(commandLine);
317318
service.convertProcessBuilderArgumentsForWsl(processBuilder, commandLine);
318319

319-
assertEquals("/mnt/c/Users/user/bin", processBuilder.environment().get("MYPATH"));
320-
assertEquals("/mnt/d/data/files", processBuilder.environment().get("DATADIR"));
320+
assertEquals("/mnt/c/Users/user/.mix", processBuilder.environment().get("MIX_HOME"));
321+
assertEquals("/mnt/d/data/mix_archives", processBuilder.environment().get("MIX_ARCHIVES"));
322+
assertEquals("/home/user/.local/share/mise/installs/elixir/1.17.3/bin:/home/user/.local/share/mise/installs/elixir/1.17.3/.mix/escripts", processBuilder.environment().get("Path"));
321323
}
322324

323325
/**

0 commit comments

Comments
 (0)