Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from Mar 16, 2023

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Feb 22, 2023

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 ryfu-msft requested a review from a team as a code owner February 22, 2023 18:31
@ryfu-msft ryfu-msft marked this pull request as draft February 22, 2023 23:02
@ryfu-msft ryfu-msft marked this pull request as ready for review February 23, 2023 17:04
@ryfu-msft
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

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

:shipit:

@candrapersada
Copy link

candrapersada commented Jun 16, 2023

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
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.

None yet

3 participants