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

When ScubaGear is imported, Internal modules are being imported into the active PowerShell session #1347

Open
buidav opened this issue Oct 1, 2024 · 0 comments
Labels
bug This issue or pull request addresses broken functionality
Milestone

Comments

@buidav
Copy link
Collaborator

buidav commented Oct 1, 2024

🐛 Summary

ScubaGear is currently not only importing the root module itself into a PowerShell session but several of its internal modules. This was done to as a fix for an issue in our functional testing code.

ScubaGear should not also importing its internal modules into the active PowerShell session as their own modules. Since this can cause namespace conflicts and developer confusion when interacting with these modules.

InternalmoduleImports

To reproduce

Import-Module .\PowerShell\ScubaGear
Get-module # displays all imported modules. 

Expected behavior

Only the ScubaGear module itself is imported when a user imports ScubaGear.

Any helpful log output or screenshots

  1. The original black magic fix in the ScubaGear Support.psm1 module. The ScubaGear is imported here and used to find the root module path. This was to fix an issue in the functional tests.
    blackMagic

  1. The fix for this issue will involve removing the import like the image below and fixing the bug that appears in the functional tests when the import is removed.
fixTheImport
  1. The other main part of the issue involves the Support.psm1 module being imported as a NestedModule inside the manifest. Support.psm1 should be moved to the root ScubaGear.psm1 module and NestedModule commented out.
supportModule
  1. How the Support.psm1 is imported above causes the internal Dependencies, RaiseFunctionCap, and Support modules to be imported into the PowerShell terminal session. Running Get-Module after importing ScubaGear picture below.
    InternalmoduleImports

  1. Example of removing the NestedModule Support.psm1 import and commenting it out.
commentOut2
  1. When importing ScubaGear after moving the Support.psm1 module import to ScubaGear.psm1 we can see that the extra imported functions no longer appear when running Get-Module. Note that the modules are still imported within ScubaGear itself but they no longer are "externally" imported as their own separate modules.
    FixedModuleIimports

Summary of the fix

  1. Fix the workaround import in Support.psm1 and the error the appears from the failing functional tests.
  2. Remove the Support.psm1 NestedModule import in the ScubaGear.psd1 manifest.
  3. Import Support.psm1 instead in ScubaGear.psm1.
@buidav buidav added the bug This issue or pull request addresses broken functionality label Oct 1, 2024
@schrolla schrolla added this to the Backlog milestone Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality
Projects
None yet
Development

No branches or pull requests

2 participants