Commit 673578d
fix: preserve user-added PATH entries by detecting PATH changes in cache
Fixes #606
When users manually export PATH (e.g., `export PATH="xxx/bin:$PATH"`),
the new paths were lost after vfox activation due to caching mechanism
only checking config file changes.
Root Cause:
- `vfox env` caches output based on config file modification times
- Cache didn't account for user-made changes to PATH environment variable
- Hook would return stale cached output without user's manual PATH exports
Solution:
- Add `CachedPath` field to ConfigState to track PATH value used for cache
- Update `HasChanged()` to detect when current PATH differs from cached PATH
- Update `Update()` to store current PATH when updating cache
- Use cross-platform `PathVarName` constant (Unix: "PATH", Windows: "Path")
Changes:
- internal/env/state.go: Add PATH tracking to detect user-made changes
- internal/env/state_test.go: Add TestConfigState_HasChanged_PathChanged
Testing:
- Added comprehensive test for PATH change detection
- All existing tests pass
- Cross-platform compatible (Unix/Linux/macOS/Windows)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>1 parent 89cefd6 commit 673578d
2 files changed
+75
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | | - | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
146 | | - | |
| 156 | + | |
147 | 157 | | |
148 | 158 | | |
149 | 159 | | |
| |||
175 | 185 | | |
176 | 186 | | |
177 | 187 | | |
| 188 | + | |
| 189 | + | |
178 | 190 | | |
179 | 191 | | |
180 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
0 commit comments