Skip to content

Commit 8bc02bc

Browse files
committed
chore: wip
1 parent 05021ca commit 8bc02bc

File tree

3 files changed

+83
-18
lines changed

3 files changed

+83
-18
lines changed

docs/config.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,31 @@ Example:
572572

573573
```bash
574574
LAUNCHPAD_VERBOSE=true LAUNCHPAD_INSTALL_PATH=~/apps launchpad install node@22
575+
576+
## Environment Activation Model
577+
578+
When you cd into a project directory that contains a dependency file (e.g. `deps.yaml`, `dependencies.yaml`, `pkgx.yml`, `launchpad.yml`, `package.json`, `pyproject.toml`), Launchpad computes:
579+
580+
- A project hash based on the physical path
581+
- A dependency fingerprint based on the content of the dependency file (md5)
582+
583+
The target environment directory is derived as:
584+
585+
```
586+
~/.local/share/launchpad/envs/<project>_<hash>-d<dep_hash>
587+
```
588+
589+
This guarantees that editing dependency versions switches to a distinct environment on the next `cd`, ensuring the correct tools are active immediately.
590+
591+
To inspect selection and cache behavior, enable verbose logging:
592+
593+
```bash
594+
export LAUNCHPAD_VERBOSE=true # or set in .env
595+
cd my-project
596+
# 🔍 Env target: env_dir=… dep_file=… dep_hash=…
597+
# 🔍 Cache check: dep=… dep_mtime=… cache_mtime=… fp_match=yes|no
598+
# 🔁 Cache invalid: dependency newer than cache
599+
# 🔁 Cache invalid: fingerprint mismatch
575600
```
576601

577602
## Shell Message Customization

docs/faq.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ Currently, Launchpad is distributed via npm/bun/yarn/pnpm. However, after global
8686

8787
### How do environment activations work?
8888

89-
When you enter a directory with a `dependencies.yaml` file:
89+
When you enter a directory with a dependency file (e.g. `deps.yaml`, `dependencies.yaml`, `pkgx.yml`, `launchpad.yml`, `package.json`, `pyproject.toml`):
9090

91-
1. **Launchpad generates a hash** based on the project path
92-
2. **Creates an isolated environment** at `~/.local/share/launchpad/envs/{hash}/`
93-
3. **Installs project packages** to the isolated environment
94-
4. **Modifies PATH** to prioritize project binaries
95-
5. **Sets environment variables** from the dependency file
96-
6. **Shows activation message** (customizable)
91+
1. Launchpad generates a hash based on the project path
92+
2. Launchpad computes a dependency fingerprint (md5 of the dependency file content)
93+
3. It creates/selects an environment at `~/.local/share/launchpad/envs/<project>_<hash>-d<dep_hash>`
94+
4. Installs project packages into that isolated environment (if needed)
95+
5. Modifies PATH to prioritize project binaries
96+
6. Sets environment variables from the dependency file
97+
7. Shows an activation message (customizable)
9798

9899
When you leave the directory, everything is automatically restored.
99100

@@ -116,6 +117,44 @@ cat dependencies.yaml
116117
launchpad dev:dump --dryrun
117118
```
118119

120+
### Why didn't my tool version switch after I changed deps.yaml?
121+
122+
When you cd into a project, Launchpad now derives the environment directory from:
123+
124+
- a hash of the project path, and
125+
- a dependency fingerprint (md5 of the dependency file content),
126+
127+
producing a path like:
128+
129+
```
130+
~/.local/share/launchpad/envs/<project>_<hash>-d<dep_hash>
131+
```
132+
133+
Changing versions in `deps.yaml` (or `dependencies.yml`, `pkgx.yml`, `launchpad.yml`, `package.json`, `pyproject.toml`, etc.) changes the fingerprint, so a new env dir is selected and the correct versions are installed/activated automatically.
134+
135+
To see this live, enable verbose logging and cd into the project:
136+
137+
```bash
138+
export LAUNCHPAD_VERBOSE=true
139+
cd my-project
140+
```
141+
142+
You’ll see a line like:
143+
144+
```
145+
🔍 Env target: env_dir=… dep_file=… dep_hash=…
146+
```
147+
148+
If the env didn’t change, confirm the `dep_file` is the one you edited and that `dep_hash` differs from the previous run. You can also inspect cache decisions:
149+
150+
```
151+
🔍 Cache check: dep=… dep_mtime=… cache_mtime=… fp_match=yes|no
152+
🔁 Cache invalid: dependency newer than cache
153+
🔁 Cache invalid: fingerprint mismatch
154+
```
155+
156+
Tip: if you previously activated a project and then edited dependencies, simply `cd .. && cd my-project` to pick up the new env.
157+
119158
### Can I disable shell messages?
120159

121160
**Yes!** You have several options:

docs/features/environment-management.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,29 @@ Environment management in Launchpad consists of two main components:
1717
When you enter a directory containing dependency files (like `dependencies.yaml`), Launchpad automatically:
1818

1919
1. **Generates a unique environment hash** based on the project path
20-
2. **Creates an isolated environment directory** at `~/.local/share/launchpad/envs/{hash}/`
21-
3. **Installs project-specific packages** to the isolated environment
22-
4. **Modifies PATH** to prioritize the project's binaries
23-
5. **Sets up environment variables** as specified in the dependency file
24-
6. **Creates deactivation hooks** to restore the original environment when leaving
25-
7. **Displays customizable messages** for activation and deactivation
20+
2. **Computes a dependency fingerprint** (md5 of the dependency file content)
21+
3. **Creates/selects an isolated environment directory** at `~/.local/share/launchpad/envs/<project>_<hash>-d<dep_hash>`
22+
4. **Installs project-specific packages** to the isolated environment
23+
5. **Modifies PATH** to prioritize the project's binaries
24+
6. **Sets up environment variables** as specified in the dependency file
25+
7. **Creates deactivation hooks** to restore the original environment when leaving
26+
8. **Displays customizable messages** for activation and deactivation
2627

2728
### Environment Hash Format
2829

2930
Launchpad uses a human-readable hash format for environment directories:
3031

31-
**Format:** `{project-name}_{8-char-hex-hash}`
32+
**Format:** `{project-name}_{8-char-hex-hash}-d{8-char-dep-hash}`
3233

3334
**Examples:**
34-
- `my-web-app_1a2b3c4d` - For a project in `/home/user/projects/my-web-app`
35-
- `api-server_5e6f7g8h` - For a project in `/work/api-server`
36-
- `final-project_7db6cf06` - For a deeply nested project
35+
- `my-web-app_1a2b3c4d-d9f1a2b3` - Project `/home/user/projects/my-web-app`, dependency fingerprint `d9f1a2b3`
36+
- `api-server_5e6f7g8h-d0c1e2f3` - Project `/work/api-server`, dependency fingerprint `d0c1e2f3`
3737

3838
**Benefits:**
3939
- **Human-readable** - Easy to identify which project an environment belongs to
40+
- **Version-aware** - Dependency changes always map to a distinct environment
4041
- **Unique** - 8-character hex hash prevents collisions between projects
41-
- **Consistent** - Same project path always generates the same hash
42+
- **Consistent** - Same project path and same deps yield the same env path
4243
- **Collision-resistant** - Different paths with same project name get different hashes
4344

4445
### Supported Dependency Files

0 commit comments

Comments
 (0)