@@ -29,8 +29,6 @@ export function shellcode(_testMode: boolean = false): string {
29
29
30
30
return `
31
31
# MINIMAL LAUNCHPAD SHELL INTEGRATION - DEBUGGING VERSION
32
- # This is a minimal version to isolate the hanging issue
33
-
34
32
# Exit early if shell integration is disabled or explicit test mode
35
33
if [[ "$LAUNCHPAD_DISABLE_SHELL_INTEGRATION" == "1" || "$LAUNCHPAD_TEST_MODE" == "1" ]]; then
36
34
return 0 2>/dev/null || exit 0
@@ -98,8 +96,6 @@ __launchpad_switch_environment() {
98
96
fi
99
97
export __LAUNCHPAD_LAST_VERBOSE_KEY="$__lp_verbose_key"
100
98
101
- # Removed verbose shell integration start message
102
-
103
99
# Known dependency filenames (keep in sync with DEPENDENCY_FILE_NAMES in src/env.ts)
104
100
local _dep_names=(
105
101
# Launchpad-specific files (highest priority)
@@ -123,7 +119,7 @@ __launchpad_switch_environment() {
123
119
# Version control files
124
120
".nvmrc" ".node-version" ".ruby-version" ".python-version" ".terraform-version"
125
121
# Package manager files
126
- "yarn.lock" "bun.lockb" ".yarnrc"
122
+ "yarn.lock" "bun.lock" "bun. lockb" ".yarnrc"
127
123
)
128
124
129
125
# Step 1: Find project directory using our fast binary (no artificial timeout)
@@ -151,21 +147,11 @@ __launchpad_switch_environment() {
151
147
152
148
# Removed verbose project detection message
153
149
154
- # Step 2: Always ensure global paths are available (even in projects)
155
- # Use ~/.local/bin first, then launchpad global bin to ensure proper path priority
150
+ # Step 2: Prepare global paths but don't add them yet
151
+ # We'll add them after project-specific paths to ensure proper precedence
156
152
local local_bin="$HOME/.local/bin"
157
153
local global_bin="$HOME/.local/share/launchpad/global/bin"
158
154
159
- # Add ~/.local/bin to PATH if not already there
160
- if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then
161
- export PATH="$local_bin:$PATH"
162
- fi
163
-
164
- # Add launchpad global bin to PATH if not already there
165
- if [[ -d "$global_bin" && ":$PATH:" != *":$global_bin:"* ]]; then
166
- export PATH="$global_bin:$PATH"
167
- fi
168
-
169
155
# Step 2.0: Detect global ready markers (persistent) to skip redundant global setup
170
156
local ready_cache_marker="$HOME/.cache/launchpad/global_ready"
171
157
local ready_global_marker="$HOME/.local/share/launchpad/global/.ready"
@@ -279,6 +265,18 @@ __launchpad_switch_environment() {
279
265
unset LAUNCHPAD_ENV_BIN_PATH
280
266
unset __LAUNCHPAD_LAST_ACTIVATION_KEY
281
267
fi
268
+
269
+ # Ensure global paths are still available when not in a project
270
+ # Add ~/.local/bin to PATH if not already there
271
+ if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then
272
+ export PATH="$local_bin:$PATH"
273
+ fi
274
+
275
+ # Add launchpad global bin to PATH if not already there
276
+ if [[ -d "$global_bin" && ":$PATH:" != *":$global_bin:"* ]]; then
277
+ export PATH="$global_bin:$PATH"
278
+ fi
279
+
282
280
return 0
283
281
fi
284
282
@@ -335,7 +333,23 @@ __launchpad_switch_environment() {
335
333
if [[ -d "$env_dir/bin" ]]; then
336
334
export LAUNCHPAD_CURRENT_PROJECT="$project_dir"
337
335
export LAUNCHPAD_ENV_BIN_PATH="$env_dir/bin"
336
+
337
+ # Remove project-specific path if it was already in PATH
338
+ export PATH=$(echo "$PATH" | sed "s|$env_dir/bin:||g" | sed "s|:$env_dir/bin||g" | sed "s|^$env_dir/bin$||g")
339
+
340
+ # Add project-specific path first (highest priority)
338
341
export PATH="$env_dir/bin:$PATH"
342
+
343
+ # Now ensure global paths are available but with lower priority
344
+ # Add ~/.local/bin to PATH if not already there (after project paths)
345
+ if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then
346
+ export PATH="$PATH:$local_bin"
347
+ fi
348
+
349
+ # Add launchpad global bin to PATH if not already there (after project and ~/.local/bin)
350
+ if [[ -d "$global_bin" && ":$PATH:" != *":$global_bin:"* ]]; then
351
+ export PATH="$PATH:$global_bin"
352
+ fi
339
353
# Removed verbose activated environment path message
340
354
# Ensure dynamic linker can find Launchpad-managed libraries (macOS/Linux)
341
355
# Build a list of library directories from the active environment and global install
@@ -387,8 +401,16 @@ __launchpad_switch_environment() {
387
401
fi
388
402
done
389
403
else
390
- # Environment not ready - user can run 'launchpad install <project>' manually when needed
391
- :
404
+ # Environment not ready - still ensure global paths are available
405
+ # Add ~/.local/bin to PATH if not already there
406
+ if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then
407
+ export PATH="$local_bin:$PATH"
408
+ fi
409
+
410
+ # Add launchpad global bin to PATH if not already there
411
+ if [[ -d "$global_bin" && ":$PATH:" != *":$global_bin:"* ]]; then
412
+ export PATH="$global_bin:$PATH"
413
+ fi
392
414
fi
393
415
fi
394
416
@@ -417,14 +439,14 @@ if [[ -n "$ZSH_VERSION" ]]; then
417
439
return 0
418
440
fi
419
441
export __LAUNCHPAD_IN_HOOK=1
420
-
442
+
421
443
# Only run the environment switching logic, not the full shell integration
422
444
__launchpad_switch_environment
423
-
445
+
424
446
# Clean up hook flag explicitly
425
447
unset __LAUNCHPAD_IN_HOOK 2>/dev/null || true
426
448
}
427
-
449
+
428
450
# Ensure hook arrays exist
429
451
if ! typeset -p chpwd_functions >/dev/null 2>&1; then
430
452
typeset -ga chpwd_functions
@@ -441,14 +463,14 @@ elif [[ -n "$BASH_VERSION" ]]; then
441
463
return 0
442
464
fi
443
465
export __LAUNCHPAD_IN_HOOK=1
444
-
466
+
445
467
# Only run the environment switching logic, not the full shell integration
446
468
__launchpad_switch_environment
447
-
469
+
448
470
# Clean up hook flag explicitly
449
471
unset __LAUNCHPAD_IN_HOOK 2>/dev/null || true
450
472
}
451
-
473
+
452
474
# Add to PROMPT_COMMAND if not already there
453
475
if [[ "$PROMPT_COMMAND" != *"__launchpad_prompt_command"* ]]; then
454
476
PROMPT_COMMAND="__launchpad_prompt_command;\$PROMPT_COMMAND"
0 commit comments