Skip to content

Fix PATH behavior of non-symlink installations for Portables/Zip - #3002

Merged
Ryan (ryfu-msft) merged 5 commits into
microsoft:masterfrom
ryfu-msft:portableRootDirBug
Mar 16, 2023
Merged

Ryan (ryfu-msft) merged 5 commits into
microsoft:masterfrom
ryfu-msft:portableRootDirBug

Conversation

@ryfu-msft

@ryfu-msft Ryan (ryfu-msft) commented Feb 22, 2023 •

Copy link
Copy Markdown
Contributor

Fixes:

Description:
When failing to create a symlink (non-developer mode or non-admin), we should be adding the package install directory directly to PATH. However, the default root directory for portable packages was always being added instead. This has been causing issues when users attempt to execute the command alias, which fails to recognize the portable executable/symlink. This is especially problematic for portable(s) in zips as their RelativeFilePath was being ignored.

Changes:

  • If we fail to create a symlink, the InstallDirectoryAddedToPath key value is set to true and the portable target directory is added directly to PATH for all portables.
  • Modified the AddToPathVariable method to take in a value to add to PATH instead of predetermining the value to add to the PATH registry. This allows for multiple values to be appended to PATH to support multiple portables in an archive scenario.
  • Installing portable from zip always write to index. Previously, there was a check to see if there was greater than 1 item in the archive before writing to the index, but this is actually a bug because it could point to a single directory. The index is also a better way to keep track of all the files that were added.

Tests:

  • Modified the SymlinkCreationFail unit tests to point to a temporary install location and verified that the temp install location is properly appended to the PATH registry during install and removed during uninstall.
  • Verified that the changes could successfully install and uninstall ffmpeg which was the example identified in the issues above.
Microsoft Reviewers: Open in CodeFlow

@ryfu-msft
Ryan (ryfu-msft) requested a review from a team as a code owner February 22, 2023 18:31
@ryfu-msft
Ryan (ryfu-msft) marked this pull request as draft February 22, 2023 23:02
@ryfu-msft
Ryan (ryfu-msft) marked this pull request as ready for review February 23, 2023 17:04
@ryfu-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yao-msft yao-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@candrapersada

candrapersada commented Jun 16, 2023 •

Copy link
Copy Markdown

Path environment variable modified; restart your shell to use the new value.

how to restart your shell to use the new value?

@yao-msft

Copy link
Copy Markdown
Contributor

how to restart your shell to use the new value?

Basically, to make the console (you are using) recognize newly added env variables, you'll have to restart it. For example, if you are running winget in Powershell, just close and start a new Powershell window. Only new instances of Powershell will recognize new portable added by winget. Same for CMD, WindowsTerminal, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants