GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixing Import-Module on Linux for special cases of NestedModules/RootModule path format by anmenaga · Pull Request #4010 · PowerShell/PowerShell

Conversation

@anmenaga

@anmenaga Andrew (anmenaga) commented Jun 14, 2017

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:
afterfix

Test results on Ubuntu 14 before the fix:
beforefix

Fix #3693

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adityapatwardhan and chuanjiao10 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Andrew added 2 commits June 14, 2017 12:29
Andrew
IPMO fix for some cases of NestedModules/RootModule path syntax
2f8f81a
Andrew
Added tests for PowerShell#3693 fix
7d03492
@anmenaga
Andrew (anmenaga) requested a review from Aditya Patwardhan (adityapatwardhan) June 14, 2017 20:17
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Jun 14, 2017
SteveL-MSFT
Steve Lee (SteveL-MSFT) reviewed Jun 16, 2017
View reviewed changes
Comment thread test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 Outdated
Import-Module $moduleFilePath
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true
}
} No newline at end of file

@SteveL-MSFT Steve Lee (SteveL-MSFT) Jun 16, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@anmenaga Andrew (anmenaga) Jun 19, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I always forget about that newline... Updated.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Andrew
Updated tests
56daa51
SteveL-MSFT
Steve Lee (SteveL-MSFT) approved these changes Jun 20, 2017
View reviewed changes

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mirichmo Mike Richmond (mirichmo) self-assigned this Jun 22, 2017
mirichmo
Mike Richmond (mirichmo) approved these changes Jun 28, 2017
View reviewed changes
@mirichmo
Mike Richmond (mirichmo) merged commit ecefb50 into PowerShell:master Jun 28, 2017
@anmenaga
Andrew (anmenaga) deleted the ImportingModulePathFix branch October 31, 2018 21:20
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Andrew @mirichmo
Fixing Import-Module on Linux for special cases of NestedModules/Root…
5b4b366
…Module path format (PowerShell#4010)

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

* Added tests for PowerShell#3693 fix

* Updated tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Awaiting requested review from adityapatwardhan
+1 more reviewer
@mirichmo Mike Richmond (mirichmo) mirichmo approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@mirichmo Mike Richmond (mirichmo)

Labels

None yet

Projects

None yet

Milestone

No milestone

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'

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@anmenaga @SteveL-MSFT @mirichmo @msftclas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.