Skip to content

Trailing slash on directory path breaks Import-Module command #5533

@pcgeek86

Description

@pcgeek86

Steps to reproduce

PS /Users/tsulli> ipmo ./git/CUSTOMMODULE/
ipmo : The specified module './git/CUSTOMMODULE/' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ ipmo ./git/CUSTOMMODULE/
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (./git/CUSTOMMODULE/:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

PS /Users/tsulli> ipmo ./git/CUSTOMMODULE
PS /Users/tsulli> gmo

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.2        CUSTOMMODULE
Binary     3.3.189.1  AWSPowerShell.NetCore               {Add-AASScalableTarget, Add-ACMCertificateTag, Add-ADSConfigurationItemsToApplication, Add-ASAAt...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     1.1.7.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.5.0.0    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     1.2        PSReadLine                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyH...

Expected behavior

Import-Module command should succeed whether or not the trailing slash is present.

Actual behavior

Adding a trailing slash to the directory path of a module causes Import-Module command to throw an exception.

Environment data

PS /Users/tsulli> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-rc
PSEdition                      Core
GitCommitId                    v6.0.0-rc
OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct  4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Cheers,
Trevor Sullivan

Metadata

Metadata

Assignees

Labels

Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions