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 — Fix powershell to update the PATH environment variable only if PATH exists by SteveL-MSFT · Pull Request #5021 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Oct 5, 2017

Copy link
Copy Markdown
Member

Linux service calling powershell may not have PATH set
only use PATH if it's not null
also fixed a test case using -TestCases without unique test name

Fix #5019

Sorry, something went wrong.

Uh oh!

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

All reactions
@SteveL-MSFT
[feature]
9cd824f
fixed code that expected PATH env var to exist
also fixed a test case using -TestCases without unique test name
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Dongbo Wang (daxian-dbw) Oct 5, 2017
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested a review from Dongbo Wang (daxian-dbw) October 5, 2017 17:18
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Andrew (anmenaga) and Jason Shirk (lzybkr) as code owners October 5, 2017 17:18
anmenaga
Andrew (anmenaga) approved these changes Oct 5, 2017
View reviewed changes

@anmenaga Andrew (anmenaga) left a comment

Copy link
Copy Markdown

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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit ba7dfcc into PowerShell:master Oct 5, 2017
@daxian-dbw Dongbo Wang (daxian-dbw) changed the title fix powershell host crash when PATH is not set Fix powershell to update the PATH environment variable only if PATH exists Oct 5, 2017
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the crash-nopath branch October 16, 2017 21:53
@chipzoller

Chip Zoller (chipzoller) commented Oct 30, 2017

Copy link
Copy Markdown

There still seems to be an issue with this after being rolled into beta 9. For example, if PATH is not set, a test script fails when calling $myvar = hostname on Linux.

"hostname : The term 'hostname' is not recognized as the name of a cmdlet, funct
ion, script file, or operable program."

If PATH is set, the script executes correctly.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Oct 30, 2017

Copy link
Copy Markdown
Member Author

PATH needs to be set for PowerShell to find exe's not in $PSHOME or current working directory, try setting $myvar to full path to hostname

chipzoller reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @daxian-dbw
Fix powershell to update the PATH environment variable only if PATH e…
314a0ab
…xists (PowerShell#5021)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
@lzybkr Jason Shirk (lzybkr) Awaiting requested review from lzybkr
1 more reviewer
@anmenaga Andrew (anmenaga) anmenaga approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Failure when being run with no PATH variable

Uh oh!

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

4 participants

@SteveL-MSFT @chipzoller @anmenaga @daxian-dbw
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.