GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enhance 'install-powershell.ps1' to work on Linux/MacOS by daxian-dbw · Pull Request #5411 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Nov 10, 2017

Copy link
Copy Markdown
Member

Enhance 'install-powershell.ps1' to work on Linux/MacOS.

When -AddToPath is specified:

  • On Windows, add the absolute destination path to the 'User' scope environment variable 'Path';
  • On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh";
  • On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Dongbo Wang (daxian-dbw) added 3 commits November 10, 2017 09:07
@daxian-dbw
Add to process path only if the process is not pwsh
6f41ad0
@daxian-dbw
Enhance 'install-powershell.ps1' to work on Linux/MacOS
b8f45da
@daxian-dbw
Minor update
982c8bd
@daxian-dbw Dongbo Wang (daxian-dbw) assigned Aditya Patwardhan (adityapatwardhan) Nov 10, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) requested review from Steve Lee (SteveL-MSFT), Travis Plunk (TravisEz13) and Aditya Patwardhan (adityapatwardhan) November 10, 2017 20:29
@daxian-dbw
Update the help content
b40d55f
TravisEz13
Travis Plunk (TravisEz13) approved these changes Nov 10, 2017
View reviewed changes
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Nov 10, 2017
View reviewed changes

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Some non-blocking comments

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/install-powershell.ps1
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$userPath = $Destination + [System.IO.Path]::PathSeparator + $userPath
[System.Environment]::SetEnvironmentVariable("Path", $userPath, "User")
Write-Verbose "'$Destination' is added to the Path" -Verbose

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Nov 10, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think, since we have CmdletBinding() we should not force -verbose

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Nov 10, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

These messages are actually intentionally written out so that a user roughly knows what the script is doing when running it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TravisEz13 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread tools/install-powershell.ps1

Expand-Archive -Path $packagePath -DestinationPath $Destination
if ($IsWinEnv) {
Expand-Archive -Path $packagePath -DestinationPath $Destination

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Nov 10, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should we delete the compressed package after expansion?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Nov 10, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The compressed package will be deleted. The compressed package is downloaded to $tempDir which will be deleted in the finally block at the end of the script.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Nov 11, 2017

Copy link
Copy Markdown
Member Author

Linux job succeeded, but the macOS job was canceled again.
Currently install-powershell.ps1 is only used in AppVeyor bootstrapping (install latest powershell core if not found), so it won't affect macOS CI run. Given that, I will merge this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 2f399e2 into PowerShell:master Nov 11, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the enhance branch November 11, 2017 01:54
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@daxian-dbw
Enhance 'install-powershell.ps1' to work on Linux/MacOS (PowerShell#5411
14bf1b4
)

Enhance 'install-powershell.ps1' to work on Linux and macOS too. A user can install release version or daily powershell core on Linux and macOS.
When `-AddToPath` is specified:
- On Windows, add the absolute destination path to the 'User' scope environment variable 'Path';
- On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh";
- On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) adityapatwardhan approved these changes
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adityapatwardhan Aditya Patwardhan (adityapatwardhan)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@daxian-dbw @TravisEz13 @adityapatwardhan
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.