@@ -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 ( {
@@ -128,16 +147,24 @@ export const installSqlmeshEnterprise = async (
128147 return tcloudBin
129148 }
130149 const projectRoot = await getProjectRoot ( )
150+ const envVariables = await getPythonEnvVariables ( )
151+ if ( isErr ( envVariables ) ) {
152+ return err ( {
153+ type : 'generic' ,
154+ message : envVariables . error ,
155+ } )
156+ }
131157 const resolvedPath = resolveProjectPath ( projectRoot )
132158 if ( isErr ( resolvedPath ) ) {
133159 return err ( {
134160 type : 'generic' ,
135161 message : resolvedPath . error ,
136162 } )
137163 }
138- const called = await execAsync ( tcloudBin . value , [ 'install_sqlmesh' ] , {
164+ const called = await execAsync ( tcloudBin . value . bin , [ 'install_sqlmesh' ] , {
139165 signal : abortController . signal ,
140166 cwd : resolvedPath . value ,
167+ env : tcloudBin . value . env ,
141168 } )
142169 if ( called . exitCode !== 0 ) {
143170 return err ( {
@@ -272,16 +299,10 @@ export const sqlmeshExec = async (): Promise<
272299 return ensured
273300 }
274301 return ok ( {
275- bin : ` ${ tcloudBin . value } sqlmesh` ,
302+ bin : tcloudBin . value . bin ,
276303 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 : [ ] ,
304+ env : tcloudBin . value . env ,
305+ args : [ "sqlmesh" ] ,
285306 } )
286307 }
287308 const binPath = path . join ( interpreterDetails . binPath ! , sqlmesh )
@@ -423,15 +444,9 @@ export const sqlmeshLspExec = async (): Promise<
423444 // TODO: Remove this once we have a stable version of tcloud that supports sqlmesh_lsp.
424445 if ( isSemVerGreaterThanOrEqual ( tcloudBinVersion . value , [ 2 , 10 , 1 ] ) ) {
425446 return ok ( {
426- bin : tcloudBin . value ,
447+ bin : tcloudBin . value . bin ,
427448 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- } ,
449+ env : tcloudBin . value . env ,
435450 args : [ 'sqlmesh_lsp' ] ,
436451 } )
437452 }
@@ -503,7 +518,9 @@ async function getTcloudBinVersion(): Promise<Result<[number, number, number], E
503518 if ( isErr ( tcloudBin ) ) {
504519 return tcloudBin
505520 }
506- const called = await execAsync ( tcloudBin . value , [ '--version' ] )
521+ const called = await execAsync ( tcloudBin . value . bin , [ '--version' ] , {
522+ env : tcloudBin . value . env ,
523+ } )
507524 if ( called . exitCode !== 0 ) {
508525 return err ( {
509526 type : 'generic' ,
0 commit comments