Skip to content

Commit 1017e9f

Browse files
committed
chore: wip
1 parent c1e34c5 commit 1017e9f

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

packages/launchpad/src/dev/dump.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,17 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
10701070
const tInstallFast = tick()
10711071
await installPackagesOptimized(localPackages, globalPackages, envDir, globalEnvDir, dryrun, quiet)
10721072
addTiming('install(packages)', tInstallFast)
1073+
// After installing in shell fast path (upgrade case), ensure PHP shims exist
1074+
try {
1075+
if (config.verbose) {
1076+
console.log('🔍 Fast path: creating PHP shims after upgrade...')
1077+
}
1078+
const tShimFast = tick()
1079+
// In shellOutput mode, do not block activation; fire-and-forget
1080+
createPhpShimsAfterInstall(envDir).catch(() => {})
1081+
addTiming('createPhpShims(async)', tShimFast)
1082+
}
1083+
catch {}
10731084
const tOutFast = tick()
10741085
outputShellCode(dir, envBinPath, envSbinPath, projectHash, sniffResult, globalBinPath, globalSbinPath)
10751086
addTiming('outputShellCode', tOutFast)
@@ -1387,6 +1398,16 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
13871398
const tInstall3 = tick()
13881399
await installPackagesOptimized(localPackages, globalPackages, envDir, globalEnvDir, dryrun, quiet)
13891400
addTiming('install(packages)', tInstall3)
1401+
// Create PHP shims synchronously in regular path to ensure immediate availability
1402+
try {
1403+
if (config.verbose) {
1404+
console.log('🔍 Regular path: creating PHP shims after install...')
1405+
}
1406+
const tShimReg = tick()
1407+
await createPhpShimsAfterInstall(envDir)
1408+
addTiming('createPhpShims', tShimReg)
1409+
}
1410+
catch {}
13901411
// Visual separator after dependency install list
13911412
try {
13921413
console.log()
@@ -1600,6 +1621,20 @@ async function installPackagesOptimized(
16001621

16011622
// Don't rethrow package installation errors - continue with partial setup
16021623
}
1624+
1625+
// After global install, ensure global binaries are linked into ~/.local/bin
1626+
try {
1627+
const { createGlobalBinarySymlinks } = await import('../install-helpers.js')
1628+
if (config.verbose) {
1629+
console.log('🔗 Creating/refreshing global binary symlinks in ~/.local/bin...')
1630+
}
1631+
await createGlobalBinarySymlinks(globalEnvDir)
1632+
}
1633+
catch (e) {
1634+
if (!quiet && !isShellIntegration) {
1635+
console.warn(`⚠️ Warning: Failed to create global binary symlinks: ${e instanceof Error ? e.message : String(e)}`)
1636+
}
1637+
}
16031638
}
16041639

16051640
// Install local packages (if any)

packages/launchpad/src/dev/shellcode.ts

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ PY
8686
if ! typeset -p precmd_functions >/dev/null 2>&1; then
8787
typeset -ga precmd_functions
8888
fi
89-
89+
9090
__launchpad_chpwd() {
9191
# Prevent infinite recursion during hook execution
9292
if [[ "$__LAUNCHPAD_IN_HOOK" == "1" ]]; then
@@ -366,6 +366,56 @@ __launchpad_switch_environment() {
366366
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
367367
printf "✅ Activated environment: %s\n" "$env_dir" >&2
368368
fi
369+
370+
# Ensure dynamic linker can find Launchpad-managed libraries (macOS/Linux)
371+
# Build a list of library directories from the active environment and global install
372+
__lp_add_unique_colon_path() {
373+
# $1=varname $2=value
374+
local __var_name="$1"; shift
375+
local __val="$1"; shift
376+
if [[ -z "$__val" ]]; then return 0; fi
377+
local __cur=""
378+
# Portable indirection via eval (works in bash and zsh)
379+
eval "__cur=\${$__var_name}"
380+
case ":$__cur:" in
381+
*":$__val:"*) : ;; # already present
382+
*)
383+
if [[ -n "$__cur" ]]; then
384+
eval "export $__var_name=\"$__val:\${$__var_name}\""
385+
else
386+
eval "export $__var_name=\"$__val\""
387+
fi
388+
;;
389+
esac
390+
}
391+
392+
# Collect candidate lib dirs
393+
local __lp_libs=()
394+
# Env-level libs
395+
if [[ -d "$env_dir/php.net" ]]; then
396+
while IFS= read -r d; do __lp_libs+=("$d/lib"); done < <(find "$env_dir/php.net" -maxdepth 2 -type d -name 'v*' 2>/dev/null)
397+
fi
398+
for dom in curl.se openssl.org zlib.net gnu.org/readline; do
399+
if [[ -d "$env_dir/$dom" ]]; then
400+
while IFS= read -r d; do __lp_libs+=("$d/lib"); done < <(find "$env_dir/$dom" -maxdepth 2 -type d -name 'v*' 2>/dev/null)
401+
fi
402+
done
403+
# Global-level libs
404+
local __lp_global="$HOME/.local/share/launchpad/global"
405+
for dom in curl.se openssl.org zlib.net gnu.org/readline; do
406+
if [[ -d "$__lp_global/$dom" ]]; then
407+
while IFS= read -r d; do __lp_libs+=("$d/lib"); done < <(find "$__lp_global/$dom" -maxdepth 2 -type d -name 'v*' 2>/dev/null)
408+
fi
409+
done
410+
411+
# Export DYLD and LD paths (prepend Launchpad libs)
412+
for libdir in "\${__lp_libs[@]}"; do
413+
if [[ -d "$libdir" ]]; then
414+
__lp_add_unique_colon_path DYLD_LIBRARY_PATH "$libdir"
415+
__lp_add_unique_colon_path DYLD_FALLBACK_LIBRARY_PATH "$libdir"
416+
__lp_add_unique_colon_path LD_LIBRARY_PATH "$libdir"
417+
fi
418+
done
369419
else
370420
# Non-blocking on-demand install with retry backoff (no artificial timeout)
371421
local cache_dir="$HOME/.cache/launchpad/shell_cache"
@@ -466,5 +516,6 @@ export function datadir(): string {
466516
}
467517

468518
function platform_data_home_default(): string {
469-
return join(process.env.HOME || '~', '.local', 'share', 'launchpad')
519+
return join(process.env.HOME || '~',
520+
'.local', 'share', 'launchpad')
470521
}

0 commit comments

Comments
 (0)