tkellogg / Jump-Location

Powershell `cd` that reads your mind
MIT License
467 stars 26 forks source link

Support for PS v2 #21

Open skalinkin opened 9 years ago

skalinkin commented 9 years ago

unziped => unlocked => installed => after run PS got that: Import-Module : The 'C:\Users\ME\Documents\Jump-Location-0.5.1\Jump.Location.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members that arenot valid ('RootModule'), then try to import the module again. At C:\Users\ME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:2 char:14

lzybkr commented 9 years ago

So you're using PowerShell V2, right? RootModule was added in V3 I think.

tkellogg commented 9 years ago

Can someone verify that RootModule was added in V3? If so, let's update the documentation to be clear that we only support V3+ and close this issue.

bpugh commented 9 years ago

Yes I was running powershell V2 on Windows 7 and received the same error. I then updated to V3 and now it runs perfectly.

tkellogg commented 9 years ago

Ok, I updated the readme to include the the dependency on V3+. It would be great if the dependency could be checked automatically but I'm closing this issue for now since it's now documented.

bpugh commented 9 years ago

Actually found the documentation for it here: http://technet.microsoft.com/library/hh849709.aspx And under RootModule it says: Note: In Windows PowerShell 2.0, this key was called "ModuleToProcess." You can use the "RootModule" parameter name or its "ModuleToProcess" alias.

So it looks like you could support V2 if you wanted by using the `ModuleToProcess' alias

tkellogg commented 9 years ago

@bpugh Do you want to take a whack at this? I unfortunately don't have access to the Microsoft dev tools at the moment, so I'm reduced to groveling for people to contribute code.

vors commented 9 years ago

Should be easy. I renamed and reopen issue.

bpugh commented 9 years ago

Sure no problem! Alternatively you could actually enforce the version by setting PowerShellVersion = '3.0' in the same file.

oising commented 9 years ago

I think support for v2 would be nice - even if v3 or higher is installed, many of us must venture into v2 land (with the -version 2 switch) for dealing with sharepoint and exchange.

bpugh commented 9 years ago

So after messing around with this for a bit I seem to be stuck on an odd error. I made the change I described above which is changing RootModule to ModuleToProcess but when I load my profile in PS v2 I get the following error:

[Jump-location] Database contains 1 records.

Import-Module : The module to process 'Load.ps1', listed in field 'ModuleToProcess' of module manifest 'C:\projects\jump-location\Jump.Location.psd1' 
was not processed because no valid module was found in any module directory.
At C:\Users\Brandon\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:8 char:14
+ Import-Module <<<<  'C:\projects\jump-location\Jump.Location.psd1'
    + CategoryInfo          : ResourceUnavailable: (Jump.Location:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

The odd thing is as you can see jump-location still starts up just fine and work just fine after that even though the error complains about not being able to find the file. I haven't been able to find a solution anywhere online. Any thoughts?

vors commented 9 years ago

@bpugh I saw same thing, but didn't have time to investigate.

bpugh commented 9 years ago

Turns out it was just a matter of renaming the file. Apparently v2 is a stickler about modules having the proper .psm1 file extension.

vors commented 9 years ago

Nice work! Let me test it

dragon788 commented 8 years ago

@vors Did you get a chance to test this and #34 ?

vors commented 8 years ago

@dragon788 I think both me and @tkellogg cannot allocate time to work on Jump-Location anymore. @tkellogg maybe do a call for maintainers?