Skip to content

Import-Module not working if psd1 and module folder has different casing (on unix)#17342

@4ndri

Description

@4ndri

Prerequisites

Steps to reproduce

  • open powershell on linux
  • import a module, where casing of the psd1 file is different to the casing of the module folder.
    run the following script for repro:
$modulesPath="$(Get-Location)/modules/"; $env:PSModulePath+= [System.IO.Path]::PathSeparator +$modulesPath$moduleName="testmodule"; New-Item-ItemType Directory -Path "$modulesPath/$moduleName"-Force >$nullNew-ModuleManifest-Path "$modulesPath/$moduleName/$($moduleName.ToUpper()).psd1"-RootModule "TestModule.psm1"-ModuleVersion 1.1Set-Content-Path "$modulesPath/$moduleName/TestModule.psm1"-Value "function mytest{'hello' }"Import-Module testmodule

Expected behavior

module names should be case insensitive. the module should load.

Actual behavior

Error: The specified module 'testmodule' was not loaded because no valid module file was found in any module directory.

Error details

Exception :  Type : System.IO.FileNotFoundException Message : The specified module 'testmodule' was not loaded because no valid module file was found in any module directory. HResult : -2147024894

Environment data

Name Value --------- PSVersion 7.2.3 PSEdition Core GitCommitId 7.2.3 OS Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 Platform Unix PSCompatibleVersions{1.0,2.0,3.0,4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

Visuals

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions