11using System . IO ;
22using System . IO . Compression ;
3+ using CliWrap ;
34using DevTools . Execution . Services ;
45using DevTools . Utilities ;
56using Microsoft . Extensions . Logging ;
@@ -23,9 +24,9 @@ public static class PythonInstaller
2324 private static string VersionMarkerPath => Path . Combine ( GetBinPath ( ) , ".pixi-version" ) ;
2425
2526 /// <summary>
26- /// Ensures pixi is installed at the locked version.
27- /// Uses a marker file to avoid spawning a child process on every startup .
28- /// Downloads only when pixi.exe is missing or the marker version differs from <see cref="PixiVersion"/> .
27+ /// Ensures pixi is installed at the locked version and can execute .
28+ /// Downloads when pixi.exe is missing or the marker version differs from <see cref="PixiVersion"/> .
29+ /// Runs <c>pixi --version</c> on every call so enterprise blocks on unknown exe trigger pip fallback .
2930 /// </summary>
3031 public static async Task SetupPixiAsync ( ILogger ? logger = null )
3132 {
@@ -35,13 +36,33 @@ public static async Task SetupPixiAsync(ILogger? logger = null)
3536 if ( IsPixiInstalled ( ) )
3637 {
3738 logger ? . ZLogInformation ( $ "Pixi v{ PixiVersion } already installed.") ;
38- return ;
39+ }
40+ else
41+ {
42+ logger ? . ZLogInformation ( $ "Downloading v{ PixiVersion } ...") ;
43+ await DownloadAndInstallAsync ( PixiVersion ) . ConfigureAwait ( false ) ;
44+ await File . WriteAllTextAsync ( VersionMarkerPath , PixiVersion ) . ConfigureAwait ( false ) ;
45+ logger ? . ZLogInformation ( $ "v{ PixiVersion } installed.") ;
46+ }
47+
48+ await VerifyPixiRunnableAsync ( logger ) . ConfigureAwait ( false ) ;
49+ }
50+
51+ private static async Task VerifyPixiRunnableAsync ( ILogger ? logger = null )
52+ {
53+ var result = await Cli . Wrap ( PixiExePath )
54+ . WithArguments ( "--version" )
55+ . WithValidation ( CommandResultValidation . None )
56+ . ExecuteAsync ( )
57+ . ConfigureAwait ( false ) ;
58+
59+ if ( result . ExitCode != 0 )
60+ {
61+ throw new InvalidOperationException (
62+ $ "pixi --version failed with exit code { result . ExitCode } .") ;
3963 }
4064
41- logger ? . ZLogInformation ( $ "Downloading v{ PixiVersion } ...") ;
42- await DownloadAndInstallAsync ( PixiVersion ) . ConfigureAwait ( false ) ;
43- await File . WriteAllTextAsync ( VersionMarkerPath , PixiVersion ) . ConfigureAwait ( false ) ;
44- logger ? . ZLogInformation ( $ "v{ PixiVersion } installed.") ;
65+ logger ? . ZLogDebug ( $ "Pixi runtime verified (exit { result . ExitCode } ).") ;
4566 }
4667
4768 private static bool IsMarkedVersion ( string version )
0 commit comments