Skip to content

Commit 7d1a9a3

Browse files
authored
If where fails on windows, run which instead (#170)
1 parent 88640ba commit 7d1a9a3

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ intellijPlatform {
4949
<li>
5050
Update minimum version to 2026.1
5151
</li>
52+
<li>
53+
Add fallback for finding rg with wsl2
54+
</li>
5255
</ul>
5356
""".trimIndent()
5457

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Update dependencies
66
- Fix ETD errors
77
- Update minimum version to 2026.1
8+
- Add fallback for finding rg with wsl2
89

910
## Version 2.2.1
1011

src/main/kotlin/com/mituuz/fuzzier/grep/backend/BackendResolver.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
package com.mituuz.fuzzier.grep.backend
2626

27+
import com.intellij.execution.process.ProcessNotCreatedException
2728
import com.intellij.openapi.components.service
2829
import com.mituuz.fuzzier.runner.CommandRunner
2930
import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService
@@ -47,14 +48,17 @@ class BackendResolver(val isWindows: Boolean) {
4748
executable: String,
4849
projectBasePath: String
4950
): Boolean {
50-
val command = if (isWindows) {
51-
listOf("where", executable)
51+
val result = if (isWindows) {
52+
try {
53+
commandRunner.runCommandForOutput(listOf("where", executable), projectBasePath)
54+
} catch (_: ProcessNotCreatedException) {
55+
// Fallback for WSL2
56+
commandRunner.runCommandForOutput(listOf("which", executable), projectBasePath)
57+
}
5258
} else {
53-
listOf("which", executable)
59+
commandRunner.runCommandForOutput(listOf("which", executable), projectBasePath)
5460
}
5561

56-
val result = commandRunner.runCommandForOutput(command, projectBasePath)
57-
5862
return !(result.isNullOrBlank() || result.contains("Could not find files"))
5963
}
6064
}

0 commit comments

Comments
 (0)