Skip to content

Commit

Permalink
Remove empty PATH entry on Windows
Browse files Browse the repository at this point in the history
With the Windows 10 release, Microsoft added an interactive editor for the PATH variable e.g. [the workflow described here](https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net80#no-net-sdk-was-found). This normalizes the PATH entry by appending a `;` at the end of all entries. Here, because we split on the `;`, we'll end up with an empty entry. Later in the activation code, the paths are normalized with `os.path.normpath` which will expand this to `.` which can affect downstream code and can cause users concern since `.` has a special meaning on POSIX based systems.
  • Loading branch information
scw committed May 8, 2024
1 parent bfa8ccd commit 77c9ac7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conda/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ def _get_starting_path_list(self):
"PATH",
clean_paths[sys.platform] if sys.platform in clean_paths else "/usr/bin",
)
if sys.platform == "win32":
# Windows 10+ has a trailing semicolon by default, remove it to prevent empty entry
path = path.strip(os.pathsep)

Check warning on line 616 in conda/activate.py

View check run for this annotation

Codecov / codecov/patch

conda/activate.py#L616

Added line #L616 was not covered by tests
path_split = path.split(os.pathsep)
return path_split

Expand Down

0 comments on commit 77c9ac7

Please sign in to comment.