Skip to content

Commit 8208b00

Browse files
authored
fix(vscode): on windows pick right exec (#4434)
1 parent 4447f75 commit 8208b00

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Whether the current platform is Windows.
3+
*/
4+
export const IS_WINDOWS = process.platform === 'win32'

vscode/extension/src/utilities/sqlmesh/sqlmesh.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { isSignedIntoTobikoCloud } from '../../auth/auth'
1010
import { execAsync } from '../exec'
1111
import z from 'zod'
1212
import { ProgressLocation, window } from 'vscode'
13+
import { IS_WINDOWS } from '../isWindows'
1314

1415
export interface SqlmeshExecInfo {
1516
workspacePath: string
@@ -47,14 +48,15 @@ export const isTcloudProject = async (): Promise<Result<boolean, string>> => {
4748
* @returns The tcloud executable for the current Python environment.
4849
*/
4950
export const getTcloudBin = async (): Promise<Result<string, ErrorType>> => {
51+
const tcloud = IS_WINDOWS ? 'tcloud.exe' : 'tcloud'
5052
const interpreterDetails = await getInterpreterDetails()
5153
if (!interpreterDetails.path) {
5254
return err({
5355
type: 'tcloud_bin_not_found',
5456
})
5557
}
5658
const pythonPath = interpreterDetails.path[0]
57-
const binPath = path.join(path.dirname(pythonPath), 'tcloud')
59+
const binPath = path.join(path.dirname(pythonPath), tcloud)
5860
if (!fs.existsSync(binPath)) {
5961
return err({type: 'tcloud_bin_not_found'})
6062
}
@@ -174,6 +176,7 @@ export const ensureSqlmeshEnterpriseInstalled = async (): Promise<
174176
export const sqlmeshExec = async (): Promise<
175177
Result<SqlmeshExecInfo, ErrorType>
176178
> => {
179+
const sqlmesh = IS_WINDOWS ? 'sqlmesh.exe' : 'sqlmesh'
177180
const projectRoot = await getProjectRoot()
178181
const workspacePath = projectRoot.uri.fsPath
179182
const interpreterDetails = await getInterpreterDetails()
@@ -220,7 +223,7 @@ export const sqlmeshExec = async (): Promise<
220223
args: [],
221224
})
222225
}
223-
const binPath = path.join(interpreterDetails.binPath!, 'sqlmesh')
226+
const binPath = path.join(interpreterDetails.binPath!, sqlmesh)
224227
traceLog(`Bin path: ${binPath}`)
225228
return ok({
226229
bin: binPath,
@@ -234,7 +237,7 @@ export const sqlmeshExec = async (): Promise<
234237
})
235238
} else {
236239
return ok({
237-
bin: 'sqlmesh',
240+
bin: sqlmesh,
238241
workspacePath,
239242
env: {},
240243
args: [],
@@ -290,6 +293,7 @@ export const ensureSqlmeshLspDependenciesInstalled = async (): Promise<
290293
export const sqlmeshLspExec = async (): Promise<
291294
Result<SqlmeshExecInfo, ErrorType>
292295
> => {
296+
const sqlmeshLSP = IS_WINDOWS ? 'sqlmesh_lsp.exe' : 'sqlmesh_lsp'
293297
const projectRoot = await getProjectRoot()
294298
const workspacePath = projectRoot.uri.fsPath
295299
const interpreterDetails = await getInterpreterDetails()
@@ -331,7 +335,7 @@ export const sqlmeshLspExec = async (): Promise<
331335
if (isErr(ensuredDependencies)) {
332336
return ensuredDependencies
333337
}
334-
const binPath = path.join(interpreterDetails.binPath!, 'sqlmesh_lsp')
338+
const binPath = path.join(interpreterDetails.binPath!, sqlmeshLSP)
335339
traceLog(`Bin path: ${binPath}`)
336340
if (!fs.existsSync(binPath)) {
337341
return err({
@@ -350,7 +354,7 @@ export const sqlmeshLspExec = async (): Promise<
350354
})
351355
} else {
352356
return ok({
353-
bin: 'sqlmesh_lsp',
357+
bin: sqlmeshLSP,
354358
workspacePath,
355359
env: {},
356360
args: [],

0 commit comments

Comments
 (0)