boxstarter icon indicating copy to clipboard operation
boxstarter copied to clipboard

Boxstarter gets installed to top of PSModulePath and overwrites Write-Host

Open mwallner opened this issue 2 years ago • 5 comments

Checklist

  • [X] I have verified this is the correct repository for opening this issue.
  • [X] I have verified no other issues exist related to my problem.
  • [X] I have verified this is not an issue for a specific package.
  • [X] I have verified this issue is not security related.

What You Are Seeing?

Any usage of Write-Host leads to Boxstarter modules being loaded. (which slows down execution of arbitrary PowerShell scripts)

What is Expected?

Boxstarter modules should only be loaded during execution of Boxstarter/Chocolatey sessions.

How Did You Get This To Happen?

  • Install Boxstarter
  • use Write-Host in a PowerShell script
  • take a look at $env:PSModulePath / Get-Command Write-Host

System Details

  • Operating System:
  • Windows PowerShell version:
  • Chocolatey CLI Version:
  • Chocolatey Licensed Extension version:
  • Chocolatey License type:
  • Terminal/Emulator:

Installed Packages

Boxstarter v3.0

Output Log

-

Additional Context

No response

mwallner avatar Feb 02 '23 16:02 mwallner

most likely it would be possible to temporary add Boxstarter modules into PSModulePath and remove it in Cleanup-Boxstarter

mwallner avatar Feb 02 '23 16:02 mwallner

most likely it would be possible to temporary add Boxstarter modules into PSModulePath and remove it in Cleanup-Boxstarter

not so straight-forward as initially suggested 😞 removing Boxstarter.BaseDir altogether would be a breaking change - currently looking into moving it to the end of *path variables, - this way it would only jump into action if a Boxstarter module get's explicitly loaded (such as in Boxstarter-choco extension module).

@flcdrg any thoughts?

Note: it seems to have been the way I think it's correct, but has been changed to fix another issue here: https://github.com/chocolatey/boxstarter/commit/4055cb10abcc6604a3aff79b0983a03068a6b49b

mwallner avatar Jan 17 '24 08:01 mwallner

Is there a way to use the modules without adding them all to PSModulePath? (or maybe just add one or some of them)

flcdrg avatar Jan 18 '24 22:01 flcdrg

Is there a way to use the modules without adding them all to PSModulePath? (or maybe just add one or some of them)

There might be. It's been a while since I was able to take a look at this. I can confirm this change does what I wanted it to / fixes a problem. If that's okay with you I'd like to get this trough in order to fix the Bug it addresses and create a follow-up issue/improvement that'll try to rip out the modules from PSModulePath and dynama-load them just from the Chocolatey extension/ BoxstarterShell script.

mwallner avatar Mar 14 '24 18:03 mwallner

Yes, fine with me

flcdrg avatar Mar 14 '24 23:03 flcdrg