Skip to content
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

Import fails with file does not exist #101

Closed
MisinformedDNA opened this issue May 3, 2018 · 8 comments
Closed

Import fails with file does not exist #101

MisinformedDNA opened this issue May 3, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@MisinformedDNA
Copy link

I successfully installed PowerTab, but when I went to import it, I get errors:

D:\Repos\corefxlab> import-module PowerTab
WARNING: Configuration File does not exist: 'System.Collections.Hashtable'
Join-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\Users\50587\Documents\WindowsPowerShell\Modules\PowerTab\1.0.0\TabExpansionLib.ps1:1226
char:39

  • ... $DatabasePath = Join-Path (Split-Path $ConfigurationPath) "TabExp ...
  •                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.Po
      werShell.Commands.JoinPathCommand

Update .NET type list in tab completion database from currently loaded types?
Loading .NET types.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

I also added the import to profile.ps1, but the error still appears every time a new PowerShell host opens.

@perplexityjeff
Copy link

perplexityjeff commented May 9, 2018

Here is more information regarding the setup of the module.

https://github.com/jasonmarcher/PowerTab/blob/master/Docs/Setup/ConfigFile.md

Run the following commands. Changing the path as you see fit.

New-TabExpansionConfig
Export-TabExpansionConfig C:\Users\USER\PowerTabConfig.xml

Then add the line below to your config.

Import-Module PowerTab -ArgumentList C:\Users\USER\PowerTabConfig.xml

This fixed it for me.

@MisinformedDNA
Copy link
Author

How would I run New-TabExpansionConfig if the module isn't imported yet?

@perplexityjeff
Copy link

perplexityjeff commented May 9, 2018 via email

@MisinformedDNA
Copy link
Author

That's the whole point. I can't import the module because it errors out.

@perplexityjeff
Copy link

perplexityjeff commented May 9, 2018

I had the same errors. You can still continue with the setup. Just ignore it as it is an error for the path missing. Continue the setup and then run the export command. Then add the command I wrote above to import it.

@jasonmarcher
Copy link
Owner

This isn't a blocked error, but I will get it fixed. The module needs to recognized when it is loading from a clean slate.

@jasonmarcher jasonmarcher self-assigned this May 22, 2018
@jasonmarcher jasonmarcher added this to the v1.1 milestone May 22, 2018
@bradrn
Copy link

bradrn commented Aug 17, 2018

I'm running into this same problem. It seems to be a problem with the New-TabExpansionConfig cmdlet:

> New-TabExpansionConfig
Join-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\PowerTab\1.0.0\TabExpansionLib.ps1:1226 char:39
+ ...     $DatabasePath = Join-Path (Split-Path $ConfigurationPath) "TabExp ...
+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand

@bradrn
Copy link

bradrn commented Aug 18, 2018

I've been investigating this issue a bit and the problem seems to be this bit in PowerTab.psm1 around line 96:

    if ($ConfigurationPath) {
        $script:ConfigurationPathParam = $ConfigurationPath
    } elseif ($PrivateData = (Parse-Manifest).PrivateData) {
        $script:ConfigurationPathParam = $PrivateData
#       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  This line is the problem!
    } elseif (Test-Path (Join-Path (Split-Path $Profile) $ConfigFileName)) {
        $script:ConfigurationPathParam = (Join-Path (Split-Path $Profile) $ConfigFileName)
    } elseif (Test-Path (Join-Path $PSScriptRoot $ConfigFileName)) {
        $script:ConfigurationPathParam = (Join-Path $PSScriptRoot $ConfigFileName)
    }

It seems that (Parse-Manifest).PrivateData is a System.Collections.Hashtable, so when it gets converted to a string, the configuration path ends up with the value "System.Collections.Hashtable" - which obviously isn't a correct path. For a temporary workaround, you can copy the line $script:ConfigurationPathParam = (Join-Path (Split-Path $Profile) $ConfigFileName) (which works on my system) and paste it back at the end of the if block so that it overwrites $script:ConfigurationPathParam` with a correct path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants