@@ -55,7 +55,7 @@ export const isTcloudProject = async (): Promise<Result<boolean, string>> => {
5555 *
5656 * @returns The tcloud executable for the current Python environment.
5757 */
58- export const getTcloudBin = async ( ) : Promise < Result < string , ErrorType > > => {
58+ export const getTcloudBin = async ( ) : Promise < Result < SqlmeshExecInfo , ErrorType > > => {
5959 const tcloud = IS_WINDOWS ? 'tcloud.exe' : 'tcloud'
6060 const interpreterDetails = await getInterpreterDetails ( )
6161 if ( ! interpreterDetails . path ) {
@@ -68,7 +68,25 @@ export const getTcloudBin = async (): Promise<Result<string, ErrorType>> => {
6868 if ( ! fs . existsSync ( binPath ) ) {
6969 return err ( { type : 'tcloud_bin_not_found' } )
7070 }
71- return ok ( binPath )
71+ const envVariables = await getPythonEnvVariables ( )
72+ if ( isErr ( envVariables ) ) {
73+ return err ( {
74+ type : 'generic' ,
75+ message : envVariables . error ,
76+ } )
77+ }
78+ return ok ( {
79+ bin : binPath ,
80+ workspacePath : interpreterDetails . resource ?. fsPath ?? '' ,
81+ env : {
82+ ...process . env ,
83+ ...envVariables . value ,
84+ PYTHONPATH : interpreterDetails . path [ 0 ] ,
85+ VIRTUAL_ENV : path . dirname ( interpreterDetails . binPath ! ) ,
86+ PATH : interpreterDetails . binPath ! ,
87+ } ,
88+ args : [ ] ,
89+ } )
7290}
7391
7492const isSqlmeshInstalledSchema = z . object ( {
@@ -96,8 +114,9 @@ export const isSqlmeshEnterpriseInstalled = async (): Promise<
96114 message : resolvedPath . error ,
97115 } )
98116 }
99- const called = await execAsync ( tcloudBin . value , [ 'is_sqlmesh_installed' ] , {
117+ const called = await execAsync ( tcloudBin . value . bin , [ 'is_sqlmesh_installed' ] , {
100118 cwd : resolvedPath . value ,
119+ env : tcloudBin . value . env ,
101120 } )
102121 if ( called . exitCode !== 0 ) {
103122 return err ( {
@@ -135,9 +154,10 @@ export const installSqlmeshEnterprise = async (
135154 message : resolvedPath . error ,
136155 } )
137156 }
138- const called = await execAsync ( tcloudBin . value , [ 'install_sqlmesh' ] , {
157+ const called = await execAsync ( tcloudBin . value . bin , [ 'install_sqlmesh' ] , {
139158 signal : abortController . signal ,
140159 cwd : resolvedPath . value ,
160+ env : tcloudBin . value . env ,
141161 } )
142162 if ( called . exitCode !== 0 ) {
143163 return err ( {
@@ -272,16 +292,10 @@ export const sqlmeshExec = async (): Promise<
272292 return ensured
273293 }
274294 return ok ( {
275- bin : ` ${ tcloudBin . value } sqlmesh` ,
295+ bin : tcloudBin . value . bin ,
276296 workspacePath,
277- env : {
278- ...process . env ,
279- ...envVariables . value ,
280- PYTHONPATH : interpreterDetails . path ?. [ 0 ] ,
281- VIRTUAL_ENV : path . dirname ( interpreterDetails . binPath ! ) ,
282- PATH : interpreterDetails . binPath ! ,
283- } ,
284- args : [ ] ,
297+ env : tcloudBin . value . env ,
298+ args : [ "sqlmesh" ] ,
285299 } )
286300 }
287301 const binPath = path . join ( interpreterDetails . binPath ! , sqlmesh )
@@ -423,15 +437,9 @@ export const sqlmeshLspExec = async (): Promise<
423437 // TODO: Remove this once we have a stable version of tcloud that supports sqlmesh_lsp.
424438 if ( isSemVerGreaterThanOrEqual ( tcloudBinVersion . value , [ 2 , 10 , 1 ] ) ) {
425439 return ok ( {
426- bin : tcloudBin . value ,
440+ bin : tcloudBin . value . bin ,
427441 workspacePath,
428- env : {
429- PYTHONPATH : interpreterDetails . path ?. [ 0 ] ,
430- VIRTUAL_ENV : path . dirname ( interpreterDetails . binPath ! ) ,
431- PATH : interpreterDetails . binPath ! ,
432- ...process . env ,
433- ...envVariables . value ,
434- } ,
442+ env : tcloudBin . value . env ,
435443 args : [ 'sqlmesh_lsp' ] ,
436444 } )
437445 }
@@ -503,7 +511,9 @@ async function getTcloudBinVersion(): Promise<Result<[number, number, number], E
503511 if ( isErr ( tcloudBin ) ) {
504512 return tcloudBin
505513 }
506- const called = await execAsync ( tcloudBin . value , [ '--version' ] )
514+ const called = await execAsync ( tcloudBin . value . bin , [ '--version' ] , {
515+ env : tcloudBin . value . env ,
516+ } )
507517 if ( called . exitCode !== 0 ) {
508518 return err ( {
509519 type : 'generic' ,
0 commit comments