@@ -739,6 +739,7 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
739
739
740
740
// Always ensure global environment is activated first, even if already ready
741
741
// This ensures global tools like bash are available for subsequent operations
742
+ let globalInstallationFailed = false
742
743
if ( globalPackages . length > 0 && ! skipGlobal ) {
743
744
const originalVerbose = config . verbose
744
745
const originalShowShellMessages = config . showShellMessages
@@ -785,13 +786,17 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
785
786
else {
786
787
console . error ( `Failed to install global packages: ${ error instanceof Error ? error . message : String ( error ) } ` )
787
788
}
789
+
790
+ // Track that global installation failed
791
+ globalInstallationFailed = true
788
792
}
789
793
790
794
config . verbose = originalVerbose
791
795
config . showShellMessages = originalShowShellMessages
792
796
}
793
797
794
798
// Install local packages to project-specific environment
799
+ let localInstallationFailed = false
795
800
if ( localPackages . length > 0 && ! localReady ) {
796
801
const originalVerbose = config . verbose
797
802
const originalShowShellMessages = config . showShellMessages
@@ -829,7 +834,7 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
829
834
830
835
cleanupSpinner ( )
831
836
const elapsed = ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 1 )
832
- process . stderr . write ( `✅ Project environment activated for ${ projectName } \x1B[2m\x1B[3m(${ elapsed } s)\x1B[0m\n` )
837
+ process . stderr . write ( `✅ Local packages installed for ${ projectName } \x1B[2m\x1B[3m(${ elapsed } s)\x1B[0m\n` )
833
838
834
839
if ( process . stderr . isTTY ) {
835
840
try {
@@ -858,6 +863,12 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
858
863
if ( errorMessage . includes ( 'ENOENT' ) || errorMessage . includes ( 'permission' ) ) {
859
864
process . stderr . write ( `💡 Check directory permissions and disk space\n` )
860
865
}
866
+ if ( errorMessage . includes ( 'End-of-central-directory signature not found' ) || errorMessage . includes ( 'zipfile' ) ) {
867
+ process . stderr . write ( `💡 Download corrupted, clear cache: launchpad cache:clear --force\n` )
868
+ }
869
+
870
+ // Track that local installation failed
871
+ localInstallationFailed = true
861
872
}
862
873
finally {
863
874
// Restore original stdout and console methods
@@ -882,9 +893,29 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
882
893
cacheSniffResult ( projectHash , sniffResult )
883
894
884
895
if ( shellOutput ) {
885
- // Always output shell code in shell output mode
886
- // This ensures environment activation even when installations partially fail
887
- // but system binaries satisfy constraints
896
+ // Determine environment state for better messaging
897
+ const hasInstallationFailures = localInstallationFailed || globalInstallationFailed
898
+ const hasRequiredPackages = localPackages . length > 0 || globalPackages . length > 0
899
+ const systemBinariesSatisfyConstraints = ( localReadyResult . missingPackages ?. length === 0 ) &&
900
+ ( globalReadyResult . missingPackages ?. length === 0 )
901
+
902
+ if ( ! hasInstallationFailures && hasRequiredPackages ) {
903
+ // Perfect case: all packages installed successfully
904
+ process . stderr . write ( `✅ Environment activated for ${ path . basename ( dir ) } \n` )
905
+ } else if ( hasInstallationFailures && systemBinariesSatisfyConstraints ) {
906
+ // Fallback case: installations failed but system binaries work
907
+ process . stderr . write ( `⚠️ Environment activated with system binaries (installations failed)\n` )
908
+ process . stderr . write ( `💡 Some packages may not be the exact requested versions\n` )
909
+ } else if ( hasInstallationFailures ) {
910
+ // Bad case: installations failed and system doesn't satisfy requirements
911
+ process . stderr . write ( `❌ Environment activation failed - required packages unavailable\n` )
912
+ process . stderr . write ( `💡 Fix installation issues and try again\n` )
913
+ return // Don't generate shell code if critical packages are missing
914
+ } else {
915
+ // No packages needed or already satisfied
916
+ process . stderr . write ( `✅ Environment ready for ${ path . basename ( dir ) } \n` )
917
+ }
918
+
888
919
outputShellCode ( dir , envBinPath , envSbinPath , projectHash , sniffResult , globalBinPath , globalSbinPath )
889
920
}
890
921
else if ( ! quiet ) {
0 commit comments