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

do not overwrite PSModulePath when setting up build environment #6697

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

mwrock
Copy link
Contributor

@mwrock mwrock commented Jun 28, 2019

The PSModulePath environment variable is where Powershell looks for modules. When entering a powershell shell, powershell will ensure that its own modules directory which include the built in modules that ship with powershell are added to this variable when the shell starts.

If a plan includes something like:

function Invoke-SetupEnvironment {
    Push-RuntimeEnv "PSModulePath" "\hab\pkgs\$pkg_origin\$pkg_name\$pkg_version\$pkg_release\Modules"
}

This will overwrite the existing PSModulePath and potentially cause powershell commands that leverage the distribution bundled modules to fail.

An example would be any plan that takes a dep on core/dsc-core which includes the above code.

This PR does 3 things:

  1. Sets the PSModulePath in the Studio creation code so that any module paths other than those included with the powershell vendored in the studio are not included.
  2. Add PSModulePath to the list of variables in hab-plan-build that should not be overwritten.
  3. Removes a function I found to be entirely dead code.

Signed-off-by: mwrock matt@mattwrock.com

Signed-off-by: mwrock <matt@mattwrock.com>
@@ -1267,7 +1267,7 @@ function Invoke-SetupEnvironmentWrapper {
# the real environment, except for PATH; for that, push the
# runtime path onto the front of the system path
foreach($k in $env["Runtime"].keys) {
Copy link
Contributor

@christophermaier christophermaier Jun 28, 2019

Choose a reason for hiding this comment

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

Is it significant that this "Runtime", while above we have "RunTime" (note capitalization)?

(same with "Buildtime" below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Powershell hash keys and variables are not case sensitive.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrmm... maybe it'd be better to be consistent.

If nothing else, it'd stop me from asking these questions 😉

@mwrock mwrock merged commit c0a30b2 into master Jun 28, 2019
@mwrock mwrock deleted the psmodulepath branch June 28, 2019 16:52
chef-ci added a commit that referenced this pull request Jun 28, 2019
Obvious fix; these changes are the result of automation not creative thinking.
@christophermaier christophermaier added Type:BugFixes PRs that fix an existing bug Focus: Studio Related to the Habitat Studio (core/hab-studio) component Platform: Windows Deals with Windows-specific behavior Type: Bug Issues that describe broken functionality and removed X-fix labels Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus :Plan Build Focus: Studio Related to the Habitat Studio (core/hab-studio) component Platform: Windows Deals with Windows-specific behavior Type: Bug Issues that describe broken functionality Type:BugFixes PRs that fix an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants