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

(#1392) Update refreshenv to detect when not in cmd shell #2756

Merged
merged 2 commits into from
Sep 30, 2022

Conversation

corbob
Copy link
Member

@corbob corbob commented Jul 1, 2022

Description Of Changes

Update the refreshenv.cmd file to detect if being run from a sub shell and properly report that it doesn't work in that scenario.

Motivation and Context

By default, if you don't have a PowerShell profile when Chocolatey is first installed, you don't get the refreshenv alias from the chocolateyProfile.psm1 PowerShell module. This means if you run refreshenv while in PowerShell it actually runs refreshenv.cmd and fails to refresh the environment.

Testing

  1. Build the solution with ./build.bat
  2. Install the built files choco upgrade chocolatey -pre -y -s ./code_drop/Packages/Chocolatey
  3. Run refreshenv in a PowerShell session
  4. Verify output regarding not supported there
  5. Import module referenced in output
  6. Run refreshenv again
  7. Verify it works as expected
  8. Run refreshenv from a cmd.exe session
  9. Verify output of refreshing variables for cmd.exe

2022-07-01_09-38-14

Change Types Made

  • Bug fix (non-breaking change)
  • Feature / Enhancement (non-breaking change)
  • Breaking change (fix or feature that could cause existing functionality to change)
  • PowerShell code changes.

Related Issue

Fixes #1392

Change Checklist

  • Requires a change to the documentation
  • Documentation has been updated
  • Tests to cover my changes, have been added
  • All new and existing tests passed.
  • PowerShell v2 compatibility checked.

Detect when the calling shell is not cmd.exe and issue a message that it
does not work on that shell.
@coveralls
Copy link

coveralls commented Jul 1, 2022

Coverage Status

Coverage remained the same at 27.584% when pulling 66baa8f on corbob:update-refreshenv into 44c5283 on chocolatey:develop.

Copy link
Member

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Looks good to me! 💖

@vexx32 vexx32 merged commit e35fe2b into chocolatey:develop Sep 30, 2022
@corbob corbob deleted the update-refreshenv branch July 12, 2023 05:08
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.

Make refreshenv.bat error if powershell.exe is being used
3 participants