FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixing Import-Module on Linux for special cases of NestedModules/RootModule path format by anmenaga · Pull Request #4010 · PowerShell/PowerShell · GitHub

Fixing Import-Module on Linux for special cases of NestedModules/RootModule path format - #4010

Merged
Mike Richmond (mirichmo) merged 3 commits into
PowerShell:masterfrom
anmenaga:ImportingModulePathFix
Jun 28, 2017
Merged

Fixing Import-Module on Linux for special cases of NestedModules/RootModule path format#4010
Mike Richmond (mirichmo) merged 3 commits into
PowerShell:masterfrom
anmenaga:ImportingModulePathFix

Conversation

Copy link
Copy Markdown

NestedModules/RootModule are fields in a module manifest (.psd1) that reference other modules using string paths. Assuming that a module is written to be cross-platform, the same psd1 module manifest should be successfully imported on both Windows and Linux platforms.
The bug is that in some cases Import-Module on Linux fails for a totally valid module. It depends on format of NestedModules/RootModule paths.

The root of the problem is using simple Path.Combine for constructing a path to the submodule, that is then tested using NativeItemExists methods, resulting in calls like
Unix.NativeMethods.IsFile("/home/testuser/TestRootModule/.\SubModule\SubModule.psm1")
which fails and Import-Module returns an error.

The fix is to resolve submodule paths using existing FileSystem provider utilities.

Test results on Ubuntu 14 after the fix:

Test results on Ubuntu 14 before the fix:

Fix #3693

Import-Module $moduleFilePath
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true
}
} No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The little red icon means you should have a trailing linefeed at the end of the file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I always forget about that newline... Updated.

Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Mike Richmond (mirichmo) merged commit ecefb50 into PowerShell:master Jun 28, 2017
Andrew (anmenaga) deleted the ImportingModulePathFix branch October 31, 2018 21:20
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…Module path format (PowerShell#4010)

* IPMO fix for some cases of NestedModules/RootModule path syntax

* Added tests for PowerShell#3693 fix

* Updated tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

NestedModules does not work on Linux if the path starts with '.' e.g. '.\folder\library.dll'

4 participants


Back | FazBrowse Home | New Git URL