|
86 | 86 | if ! typeset -p precmd_functions >/dev/null 2>&1; then
|
87 | 87 | typeset -ga precmd_functions
|
88 | 88 | fi
|
89 |
| - |
| 89 | +
|
90 | 90 | __launchpad_chpwd() {
|
91 | 91 | # Prevent infinite recursion during hook execution
|
92 | 92 | if [[ "$__LAUNCHPAD_IN_HOOK" == "1" ]]; then
|
@@ -366,6 +366,56 @@ __launchpad_switch_environment() {
|
366 | 366 | if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
|
367 | 367 | printf "✅ Activated environment: %s\n" "$env_dir" >&2
|
368 | 368 | 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 |
369 | 419 | else
|
370 | 420 | # Non-blocking on-demand install with retry backoff (no artificial timeout)
|
371 | 421 | local cache_dir="$HOME/.cache/launchpad/shell_cache"
|
@@ -466,5 +516,6 @@ export function datadir(): string {
|
466 | 516 | }
|
467 | 517 |
|
468 | 518 | 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') |
470 | 521 | }
|
0 commit comments