esp-rs / espup

Tool for installing and maintaining Espressif Rust ecosystem.
Apache License 2.0
224 stars 23 forks source link

Installation duplicates contents of PATH environment variable on Windows #410

Closed marsfan closed 9 months ago

marsfan commented 9 months ago

Bug description

When using espup on Windows, the tool messes up user PATH environment variable in two ways.

  1. It duplicates all existing entries in the user PATH environment variable
  2. It adds all entries in the system PATH environment variable to the user PATH environment variables

To help clear things up, the following is a bare-bones example of what I am seeing.

Before running espup I have the following configuration

User PATH varriable

C:\path1
C:\path2

System PATH variable

C:\WINDOWS

After running, the system PATH environment variable remains unchanged, but the user PATH environment variable is as follows:

C:\WINDOWS
C:\path1
C:\path2
C:\users\ME\.rustup\toolchains\esp\xtensa-esp32-elf-clang\esp-clang\bin
C:\users\ME\.rustup\toolchains\esp\xtensa-esp-elf\bin
C:\path1
C:\path2

As you can see, the system PATH members are prepended to the PATH members, and then the user PATH members are duplicated.

To Reproduce

Steps to reproduce the behavior:

  1. Use espup to install the toolchain
  2. View the list of defined user environment variables in Windows.

Expected behavior

Only the additional paths are added to the user PATH environment variable necessary for compiling Rust programs for the ESP32 have been added.

Screenshots

Environment

Additional context

SergioGasquez commented 9 months ago

I see, it looks like the std::env::var mixes both user and system PATH environment variable. I did some testing and the following seems to fix the issue, could you test and verify that the issue is solved:

cargo uninstall espup
cargo install espup --git https://github.com/SergioGasquez/espup --branch fix/windows-path

You may need to remove the duplicated entries from system in your user env path

marsfan commented 9 months ago

@SergioGasquez That seems to have fixed it.

SergioGasquez commented 9 months ago

Thanks for testing the issue! I will probably cut a release before the next Xtensa Rust release

marsfan commented 9 months ago

Awesome. I'll have to give it a go then. I've been having a few different issues with getting the ESP32 working with Windows that lead to a lot of uninstalls and re-installs. Having the tool fix the path automatically will help me with that.

marsfan commented 9 months ago

@SergioGasquez This is a bit off-topic, but you mentioned "Before the next Xtensa Rust release" Do you have a recommendation on the best way to keep track of when those happen, so I know when I need to run espup to get the new version of the toolchain?

SergioGasquez commented 9 months ago

@SergioGasquez This is a bit off-topic, but you mentioned "Before the next Xtensa Rust release" Do you have a recommendation on the best way to keep track of when those happen, so I know when I need to run espup to get the new version of the toolchain?

Usually, the schedule is very similar to the stable channel (see https://forge.rust-lang.org/#current-release-versions for dates), but we may have some delay since we sometimes give a few days before marking the release as latest on gh. Releases are published in https://github.com/esp-rs/rust-build/releases so you can enable notifications for it or just join the matrix channel (https://matrix.to/#/#esp-rs:matrix.org) where we notify when the new version is published.

marsfan commented 9 months ago

Awesome. I enabled release notifications. Thanks