Skip to content

Unix implementation does not use PSModule env variable #2677

@fatso83

Description

@fatso83

I have read the known issues, faq and searched for open issues matching this, and I found nothing, so hoping this is new to you. I tried splitting up a script into modules, and found that I need to add the current path to PSModulePath in order to do so. Whatever I did, Powershell never found the module. After doing the same in Windows, I discovered it perfectly there immediately. I can see no issues regarding casing here, so that tip does not seem to apply here.

Steps to reproduce

First, download latest version 6 alpha build (12 as of now) for Mac. Then clone and run the test case:

git clone https://github.com/fatso83/powershell-module-test
cd powershell-module-test
powershell -File bar-test.ps1

Expected behavior

This should be output (which is the case on Windows, using Powershell 3):

Oh, hello there. You are now loading the Bar module  

Bar says hello

Actual behavior

Import-Module : The specified module 'Bar' was not loaded because no valid module file was found in any module directory.
At /Users/carl-erik.kopseng/powershell-module-test/bar-test.ps1:9 char:1
+ Import-Module Bar
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (Bar:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

BarHello : The term 'BarHello' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At /Users/carl-erik.kopseng/powershell-module-test/bar-test.ps1:12 char:8
+ $res = BarHello
+        ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (BarHello:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.12
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-By DesignThe reported behavior is by design.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions