Commit 068b94b
fix: use shell-specific conda activation and check conda init status (Fixes microsoft#1313) (microsoft#1321)
## Summary
Fix conda activation on non-Windows systems (Linux/macOS/WSL) to use
shell-specific activation commands instead of a generic `source
activate` for all shells. Adds Fish shell support and checks shell
profiles to determine if `conda init` has been run.
## Changes
- **Shell-specific activation on non-Windows
(`nonWindowsGenerateConfig`):**
- Bash/ZSH/SH: source `conda.sh` + `conda activate`, falls back to
`source activate <env>`
- Fish: source `conda.fish` + `conda activate`, falls back based on
`conda init fish` status
- PowerShell: use `conda-hook.ps1` + `conda activate`, falls back based
on `conda init powershell` status
- When no sourcing script is found and `conda init` hasn't been run,
uses the full conda path (gives an actionable error)
- When `conda init` has been run, uses bare `conda` (shell function is
set up on startup)
- **Shell profile conda init detection
(`checkCondaInitInShellProfiles`):**
- Scans `.bashrc`, `.zshrc`, `config.fish`, PowerShell profiles for
`conda initialize` blocks
- Respects `XDG_CONFIG_HOME` for Fish and PowerShell paths
- Checks Fish `conf.d/conda.fish` (newer conda places init there)
- **Fish shell sourcing script discovery (`getCondaFishPath`):**
- Searches `etc/fish/conf.d/conda.fish`,
`shell/etc/fish/conf.d/conda.fish`, `Library/etc/fish/conf.d/conda.fish`
- **Added Fish to `ShellSourcingScripts` interface and
`generateShellActivationMapFromConfig`**
## Tests
- 11 tests for `checkCondaInitInShellProfiles` (conda init detection per
shell, XDG_CONFIG_HOME, multiple shells)
- 12 tests for `nonWindowsGenerateConfig` (shell-specific activation,
init status fallback, deactivation)
## Related
- Fixes microsoft#1313
- PET issue for cross-OS conda discovery in WSL:
microsoft/python-environment-tools#369
---------
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>1 parent b613cf9 commit 068b94b
File tree
4 files changed
+669
-8
lines changed- src
- managers/conda
- test/managers/conda
4 files changed
+669
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
| 55 | + | |
40 | 56 | | |
41 | 57 | | |
42 | 58 | | |
| |||
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
| 78 | + | |
62 | 79 | | |
63 | 80 | | |
64 | 81 | | |
| |||
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
77 | 101 | | |
78 | 102 | | |
79 | 103 | | |
| |||
116 | 140 | | |
117 | 141 | | |
118 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
119 | 146 | | |
120 | 147 | | |
121 | 148 | | |
| |||
148 | 175 | | |
149 | 176 | | |
150 | 177 | | |
| 178 | + | |
151 | 179 | | |
152 | 180 | | |
153 | 181 | | |
| |||
178 | 206 | | |
179 | 207 | | |
180 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
181 | 218 | | |
182 | 219 | | |
183 | 220 | | |
184 | 221 | | |
185 | 222 | | |
186 | 223 | | |
187 | 224 | | |
| 225 | + | |
188 | 226 | | |
189 | 227 | | |
190 | 228 | | |
191 | 229 | | |
192 | 230 | | |
193 | 231 | | |
194 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 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 | + | |
195 | 306 | | |
196 | 307 | | |
197 | 308 | | |
| |||
308 | 419 | | |
309 | 420 | | |
310 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
311 | 440 | | |
312 | 441 | | |
313 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
| |||
579 | 588 | | |
580 | 589 | | |
581 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
582 | 594 | | |
583 | 595 | | |
584 | 596 | | |
| |||
648 | 660 | | |
649 | 661 | | |
650 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
651 | 770 | | |
652 | 771 | | |
653 | 772 | | |
| |||
0 commit comments