-
-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module no-longer loads after #376 (manifest moved to src/ directory). #467
Comments
The issue is separating the artifacts that ship as part of the module from the artifacts that don't ship. The files under The preferred mechanism for using the module is to install it from the PowerShell Gallery via Install-Module. If you are developing for posh-git, then import the module by path. This is what I put in my profile: Import-Module ~\GitHub\dahlbyk\Posh-Git\src\posh-git.psd1 |
It's worth noting that I ran into this here, and at the time it seemed easiest to just work around it. But then I hit it again here while publishing to the PowerShell Gallery. As @rkeithhill notes, you should still be able to Even if we do get to the point where we need an explicit build step, I don't see much harm in moving everything in @rkeithhill talk me out of this? |
Adding another level under src while we don't have a build process is fine. I'm not going to talk you out of it. :-) Other PowerShell module repos that do have a build process, build to either As a community starting to work on standardizing the build process for PowerShell modules, we're trying to figure out what's best. But I do know that once you go down the signed script path, you do not want to be signing (modifying) the original (src) scripts. Likewise, you don't really want to be generating files into src or the root of the repo. You could I suppose gitignore those files so accidental commit doesn't become an issue but then |
@bgshacklett before I make this change, can you confirm that moving everything under |
@dahlbyk I checked out the v0.7.1 tag, then manually moved the contents of I must admit that I don't understand how the module is being found at all. I was under the impression that a module folder must exist directly below one of the locations in $env:PSModulePath; I was not aware that PowerShell would recurse into the path to look for modules; it's always nice to learn something new. Shell output: PS ~> mv ~\Documents\WindowsPowerShell\Modules\posh-git\src\* ~\Documents\WindowsPowerShell\Modules\posh-git\src\posh-git\
PS ~> powershell
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS ~> get-module posh-git
PS ~> Import-Module posh-git # Note that Tab Completion is successful
Import-Module : The specified module 'posh-git' was not loaded because no
valid module file was found in any module directory.
At line:1 char:1
+ Import-Module posh-git
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (posh-git:String) [Import-M
odule], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
ands.ImportModuleCommand
PS ~> Get-Module posh-git -ListAvailable
Directory:
[redacted]\Documents\WindowsPowerShell\Modules\posh-git\src
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.7.1 posh-git {Invoke-NullCoales...
PS ~> Get-SshAgent
14924
# a change in the prompt indicates that posh-git has been loaded.
~> Get-Module posh-git
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.7.1 posh-git {Add-PoshGitToProf...
~> |
This kind of thing is maddening. If the file is valid, why does its parent path matter! To confirm, posh-git is not found by |
Sorry I never replied. I suspect my browser must have crashed and I lost track of what I was working on at the time. I'm seeing the same behavior regardless of whether the manifest is at At any rate, moving the module to |
PowerShelll looks under a |
Unless we need to compile something, a build process doesn't seem like it should be necessary to run a fresh clone. So if I'm understanding this correctly, the only way to reasonably fix the posh-git-as-submodule scenario (assuming the submodule folder is named |
Actually a build process doesn't have to be that complicated and can be handy especially for publishing. For instance, we can add optional params to the build to allow the prerelease value to be tweaked in the PSD1 file. Other than that, the build could simply be a copy of the src contents into a folder named after the version. This also has the benefit of allowing you to have both a |
To clarify, automating the release process would be rad. But it doesn't seem like it should be necessary to build before |
You mean If you want to import by name then you already have to do something - you have to modify $env:PSModulePath and if you do that via the control panel applet, you'll have to restart PowerShell to get the new value. In general, I don't recommend folks muck with their PSModulePath. You're asking for trouble if you screw it up. |
Yeah, sorry, I mean Not a deal-breaker, but if we can trivially fix it (e.g. move the module definition up into the root) without breaking anything else... |
System Details
Issue Description
My method of installation is to add this repository as a submodule under my PowerShell profile's Modules directory and source the example profile. This has worked great for a significant period of time. Unfortunately, after updating to 0.7.1, I found that the module was no-longer available for import. I see that #376 moved the module manifest to the src/ directory which appears to have caused the problem. Has there been any discussion about this behavior? While I can certainly pull this module out of the PowerShell gallery, being able to just perform a recursive clone of my profile made things very simple and quick to get new workspaces set up.
Thank you for your time.
The text was updated successfully, but these errors were encountered: