@@ -16,7 +16,13 @@ import {
16
16
platformSpecificBinaryName ,
17
17
platformSpecificNodePackageName ,
18
18
} from "./constants" ;
19
- import { config , fileExists , getLspBin , safeSpawnSync } from "./utils" ;
19
+ import {
20
+ config ,
21
+ fileExists ,
22
+ getLspBin ,
23
+ type SafeSpawnSyncOptions ,
24
+ safeSpawnSync ,
25
+ } from "./utils" ;
20
26
21
27
export default class Locator {
22
28
private get globalNodeModulesPaths ( ) : Record < string , Uri | undefined > {
@@ -63,8 +69,19 @@ export default class Locator {
63
69
this . biome . logger . debug ( `🔍 Unshimming Biome binary at "${ biome . fsPath } "` ) ;
64
70
65
71
try {
72
+ const spawnSyncOptions : SafeSpawnSyncOptions = { } ;
73
+
74
+ // Set the current working directory to the project root, if it exists. This runs the `biome` binary from the
75
+ // project root in case the user's local development environment depends on this, such as when using `asdf`.
76
+ if ( this . biome . workspaceFolder ?. uri )
77
+ spawnSyncOptions . cwd = this . biome . workspaceFolder . uri . fsPath ;
78
+
66
79
// Check the version of Biome
67
- const version = safeSpawnSync ( biome . fsPath , [ "--version" ] )
80
+ const version = safeSpawnSync (
81
+ biome . fsPath ,
82
+ [ "--version" ] ,
83
+ spawnSyncOptions ,
84
+ )
68
85
?. split ( "Version: " ) [ 1 ]
69
86
?. trim ( ) ;
70
87
@@ -83,7 +100,11 @@ export default class Locator {
83
100
}
84
101
85
102
// If the version is 2 or higher, we can safely unshim
86
- const realPath = safeSpawnSync ( biome . fsPath , [ "__where_am_i" ] ) ;
103
+ const realPath = safeSpawnSync (
104
+ biome . fsPath ,
105
+ [ "__where_am_i" ] ,
106
+ spawnSyncOptions ,
107
+ ) ;
87
108
88
109
if ( ! realPath ) {
89
110
this . biome . logger . warn (
@@ -153,21 +174,21 @@ export default class Locator {
153
174
*
154
175
* This strategy is responsible for finding the Biome binary as specified
155
176
* in the user's settings in the `biome.lsp.bin` configuration option.
156
- *
177
+ *
157
178
* This strategy supports platform-specific settings, meaning that the user can
158
179
* specify different binaries for different combos of OS, architecture and libc.
159
- *
180
+ *
160
181
* If the `biome.lsp.bin` setting is specified as a string, the strategy will
161
182
* attempt to locate the binary at the specified path. If the binary is not found
162
183
* at the specified path, the strategy will return `undefined`.
163
- *
184
+ *
164
185
* If the `biome.lsp.bin` setting is specified as an object, the strategy will
165
186
* attempt to locate the binary at the specified path for the current platform
166
187
* (OS, architecture and libc). If the binary is not found at the specified path,
167
188
* the strategy will return `undefined`. The keys of the object are the OS, architecture
168
189
* and libc combos, concatenated with a dash (`-`), and the values are the paths to
169
190
* the binaries.
170
- *
191
+ *
171
192
* Example:
172
193
*
173
194
* ```json
0 commit comments