Skip to content

Verbose output on function exported but isn't actually exported (nor intended to be exported) from script module #8740

Closed

Description

Steps to reproduce

New-ModuleManifest -Path ./noexport.psd1 -RootModule noexport.psm1 -FunctionsToExport @()
 "function test-notExported {}" > noexport.psm1
ipmo ./noexport.psd1 -verbose

Expected behavior

VERBOSE: Loading module from path '/Users/steve/test/Modules/noexport/noexport.psd1'.
VERBOSE: Loading module from path '/Users/steve/test/Modules/noexport/noexport.psm1'.

Actual behavior

VERBOSE: Loading module from path '/Users/steve/test/Modules/noexport/noexport.psd1'.
VERBOSE: Loading module from path '/Users/steve/test/Modules/noexport/noexport.psm1'.
VERBOSE: Exporting function 'test-notExported'.

Note that the function isn't actually exported, seems like the verbose message is in the wrong place in the code.

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0-preview.3
PSEdition                      Core
GitCommitId                    6.2.0-preview.3
OS                             Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/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

Activity

  1. SteveL-MSFT commented on Jan 24, 2019

    @SteveL-MSFT
    MemberAuthor

    Note that this came up as importing Az module with -Verbose shows a "Exporting function Test-DotNet" message. However, after debugging this, it appears that for a function to be visible in the current session, it is "exported" and then "imported". So you would see both verbose messages. This seems by-design, but certainly a bit confusing. Perhaps we could change the "Exporting function ..." message to something else to make it more obvious. However, since I haven't seen lots of mention about this, putting it up-for-grabs on a suggestion.

  2. added
    WG-Enginecore PowerShell engine, interpreter, and runtime
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif
    on Jan 24, 2019
  3. BrucePay commented on Jan 25, 2019

    @BrucePay
    Collaborator

    Steve Lee (@SteveL-MSFT) This is by design. A command is exported from the .psm1 module and then imported into the .psd1 module which may, in turn, export it into the caller's session state. A .psd1 file is essentially a "view" into the set of modules it aggregates. You get the two verbose messages so if something isn't exported, you can tell at what level the problem exists i.e. wasn't exported at the .psm1 level or it wasn't exported at the .psd1 level making, it easier to debug.

  4. vexx32 commented on Jan 25, 2019

    @vexx32
    Collaborator

    Bruce Payette (@BrucePay) Steve Lee (@SteveL-MSFT) perhaps the data can be useful, but what's actually happening needs to be clarified in the messages, as for anyone who doesn't know exactly how module leading works, that's extremely unclear. 😄

    Perhaps the first messages could say something more like "Discovered function X in X.psm1"

    And the second more along the lines of "Discovered function/alias X in X.psd1, matched to X in X.psm1; exporting function to session."

    Just something that gives enough clarity on where the importing routines are in the process. Ideally, I think verbose or debug messages should provide useful data that someone receiving can either act upon or have a good idea of who to call upon to look at it.

  5. SteveL-MSFT commented on Jan 25, 2019

    @SteveL-MSFT
    MemberAuthor

    Rain Sallow (/u/ta11ow) (@vexx32) Bruce Payette (@BrucePay) I'm not suggesting removing the existing verbose messages, but to make them more clear. This was initially brought to my attention by a PowerShell MVP so if they were confused, I can only imagine non-MVP users being confused. "Discovered" seems like a good description that a user can understand.

  6. SteveL-MSFT commented on Jan 30, 2019

    @SteveL-MSFT
    MemberAuthor

    @PowerShell/powershell-committee reviewed this, the messages come from functions being exported from the psm1 and if there is a psd1 there is a corresponding message being imported if it passes the filter FunctionsToExport. Without understanding the internals, the current messages can be confusing to the user. Having indentation would help with the nesting of the modules. Recommendation is to change:

    Exporting function `test`
    

    to

    Exporting function `test` from noexport.psm1
    Not exporting function `test` from noexport.psm1 via noexport.psd1
    
  7. added
    Committee-ReviewedPS-Committee has reviewed this and made a decision
    and removed
    Review - CommitteeThe PR/Issue needs a review from the PowerShell Committee
    on Jan 30, 2019
  8. pougetat commented on Feb 1, 2019

    @pougetat

    Hey Steve Lee (@SteveL-MSFT) ,
    I'm going to update my PR to reflect this. This is just to notify that I am still working on this and will have some modifications over the weekend. :)

  9. vexx32 commented on Jun 9, 2019

    @vexx32
    Collaborator

    pougetat (@pougetat) are you still working on this? 🙂

  10. pougetat commented on Jun 28, 2019

    @pougetat

    Rain Sallow (/u/ta11ow) (@vexx32) Hey, really sorry about this late response. I'm not working on this but if you want to work on it then I suggest looking at the PR that I closed. I learned some interesting things regarding the Import-Module cmdlet talking with Rob Holt (@rjmholt)

  11. rjmholt commented on Jun 28, 2019

    @rjmholt
    Collaborator

    👋

  12. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  13. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  14. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  15. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-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