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

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

do not overwrite PSModulePath when setting up build environment
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) {

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 28, 2019

Contributor

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

(same with "Buildtime" below)

This comment has been minimized.

Copy link
@mwrock

mwrock Jun 28, 2019

Author Contributor

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

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 28, 2019

Contributor

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

4 of 5 checks passed

buildkite/habitat-sh-habitat-master-verify Build #2541 failed (38 minutes, 35 seconds)
Details
DCO This commit has a DCO Signed-off-by
Details
buildkite/habitat-sh-habitat-master-website Build #3072 passed (1 minute, 55 seconds)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
expeditor/config-validation Validated your Expeditor config file
Details

@mwrock mwrock deleted the psmodulepath branch Jun 28, 2019

chef-ci added a commit that referenced this pull request Jun 28, 2019

Update CHANGELOG.md with details from pull request #6697
Obvious fix; these changes are the result of automation not creative thinking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.