Skip to content

Commit 2b2a8f1

Browse files
authored
fix: use Toolbox cache for Windows plugin installation via Gradle (#354)
Toolbox 3.7 looks for external plugins inside its Windows cache, but the Gradle task (installPlugin) copied them to a different directory, so Toolbox ignored the installed plugin. Use the platform-specific plugin locations for installation and cleanup, and correct the related documentation while keeping the existing Linux and macOS paths.
1 parent eb1aab8 commit 2b2a8f1

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ or from [Coder's Github Release page](https://github.com/coder/coder-jetbrains-t
3232

3333
The next step is to copy the zip content to one of the following locations, depending on your OS:
3434

35-
* Windows: `%LocalAppData%/JetBrains/Toolbox/plugins/com.coder.toolbox`
35+
* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/com.coder.toolbox`
3636
* macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/com.coder.toolbox`
3737
* Linux: `~/.local/share/JetBrains/Toolbox/plugins/com.coder.toolbox`
3838

‎buildSrc/src/main/kotlin/PluginUtils.kt‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,29 @@ import kotlin.io.path.div
88
* Resolves the Toolbox plugin install directory for the current OS.
99
*/
1010
fun getPluginInstallDir(extensionId: String): Path {
11-
val userHome = System.getProperty("user.home").let { Path.of(it) }
12-
val pluginsDir = when (OS.current()) {
13-
OS.WINDOWS -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
14-
// currently this is the location that TBA uses on Linux
15-
OS.LINUX -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
16-
OS.MAC -> userHome / "Library" / "Caches"
11+
val userHome = Path.of(System.getProperty("user.home"))
12+
val toolboxDir = when (OS.current()) {
13+
OS.WINDOWS -> {
14+
val localAppData = System.getenv("LOCALAPPDATA")
15+
?.takeIf { it.isNotBlank() }
16+
?.let { Path.of(it) }
17+
?: (userHome / "AppData" / "Local")
18+
localAppData / "JetBrains" / "Toolbox" / "cache"
19+
}
20+
21+
OS.LINUX -> {
22+
val dataHome = System.getenv("XDG_DATA_HOME")
23+
?.takeIf { it.isNotBlank() }
24+
?.let { Path.of(it) }
25+
?: (userHome / ".local" / "share")
26+
dataHome / "JetBrains" / "Toolbox"
27+
}
28+
29+
OS.MAC -> userHome / "Library" / "Caches" / "JetBrains" / "Toolbox"
1730
else -> error("Unknown os")
18-
} / "JetBrains" / "Toolbox" / "plugins"
31+
}
1932

20-
return pluginsDir / extensionId
33+
return toolboxDir / "plugins" / extensionId
2134
}
2235

2336
/**

‎src/main/kotlin/com/coder/toolbox/feed/IdeFeedManager.kt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import kotlin.jvm.optionals.getOrNull
2323
* This manager handles fetching IDE information from JetBrains data services,
2424
* caching the results locally, and supporting offline mode.
2525
*
26-
* Cache files are stored in platform-specific locations:
27-
* - macOS: ~/Library/Application Support/JetBrains/Toolbox/plugins/com.coder.toolbox/
28-
* - Linux: ~/.local/share/JetBrains/Toolbox/plugins/com.coder.toolbox/
29-
* - Windows: %LOCALAPPDATA%/JetBrains/Toolbox/plugins/com.coder.toolbox/
26+
* Cache files are stored in the Coder Toolbox data directory:
27+
* - macOS: ~/Library/Application Support/coder-toolbox/
28+
* - Linux: ${XDG_DATA_HOME:-~/.local/share}/coder-toolbox/
29+
* - Windows: %LOCALAPPDATA%/coder-toolbox/
3030
*/
3131
class IdeFeedManager(
3232
private val context: CoderToolboxContext,

0 commit comments

Comments
 (0)