Repository navigation
Import-Module not working if psd1 and module folder has different casing (on unix) #17342
Description
Activity
- addedNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.
on May 14, 2022 this issue is similar to #1621 which was resolved in PR #5097. but the assumption was made, that psd1/psm1 file always has the same casing as the folder name. I think that's wrong, because there are other methods to install modules than with PSGet.
i.e. if dependencies are installed with dotnet/nuget. nuget forces lowercase for package folder (NuGet/Home#3840). this results in different casing for the module folder name and the psd1 file.
Reacted by Luca Hostettlermodule names should be case insensitive.
This is not Windows. Script names are also case sensitive.
module names are already case-insensitive (even on Unix). the discussion about case-sensitivity of modules was resolved here: #706 (comment)
the following table shows the current behavior of
Import-ModuleModuleFolder psd1-File Import-Module ByName Result testmodule testmodule.psd1 testmodule works testmodule testmodule.psd1 TESTmodule works testmodule TestModule.psd1 testmodule error testmodule TestModule.psd1 TestModule error I expect that all these possibilities should work.
I just ran into this issue as well and spent a couple of hours trying to figure out what is going on. At the very least the error message should be improved.
rickandersen-forte commented
on Oct 15, 2023 More actionsDoesn't this cause all nuget packages to fail? Or at least, all nuget packages that include an uppercase letter? If I understand correctly (and I'm not sure I do), it has been decided in nuget #3840 that all nuget packages will be forced to lowercase. As a result, all PS modules that include a capital letter installed via a nuget package would get an invalid directory name and thus would fail on any case-sensitive file system. I'm sure that's not happening, so what am I missing? Is there something I need to do to get Publish-PSResource to generate a mixed-case nupkg file?
if the module is installed with PSGet, everything works. PSGet installs the module with correct casing.
but if the module is installed with nuget, upper cased modules can't be imported on unix filesystem. in #5097 (comment) they assumed that casing of folder and psd1 or psm1 is always the same. nuget breaks this assumption with its lowercasing.
JamesWTruher commented
on Oct 28, 2024 CollaboratorMore actionsThe WG discussed this, and while at first blush it may appear this is easily addressed, there are some very subtle issues that may arise. Most problematic is that if there are multiple psd1 files, and they all have inconsistencies with regard to case against reality, where none are correct, what should be behavior be? In this case, just describing that would be quite voluminous. Because the module name refers to something on the filesystem, the WG believes that we should be case sensitive in those situations, and believe that we are working as designed at present.
We suggest that tooling should be improved (such as PSResourceGet) to catch these issues in the authoring and publishing process.
Reacted by Jakub Tomkiewicz- addedResolution-By DesignThe reported behavior is by design.The reported behavior is by design.and removedNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.
on Oct 28, 2024 microsoft-github-policy-service commented
on Oct 30, 2024 ContributorMore actionsThis issue has been marked as by-design and has not had any activity for 1 day. It has been closed for housekeeping purposes.
microsoft-github-policy-service commented
on Oct 30, 2024 ContributorMore actions📣 Hey 4ndri (@4ndri), how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback
RE: "working as intended. issue with
PSResourceGet".I agree with this, as the last time I've checked, like a year ago, it was
PSResourceGetthat was installing modules on linux into incorrectly cased directories (PowerShell/PSResourceGet#1402, PowerShell/PSResourceGet#1446).
Prerequisites
Steps to reproduce
run the following script for repro:
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
Environment data
Visuals
No response