badmotorfinger / z

Save time typing out directory paths in PowerShell by jumping around instead.
The Unlicense
434 stars 33 forks source link

Exception when cd-ing #34

Closed bwets closed 6 years ago

bwets commented 7 years ago

I get this when I cd to a folder:

System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary2 functionsToDefine, List1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args) at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args) at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord()

It comes from z as it does not happens when the module is not loaded. It also started recently, even after updating to latest 1.1.19.

I should note that it happens on Windows 10 Fall Creators Update build 16299.15

Any idea?

badmotorfinger commented 7 years ago

Is this any folder? Can you please give me the example of folder name.

bwets commented 7 years ago

any folder like c:\Windows. Rooted or not is the same Edit: also when cd ..

badmotorfinger commented 7 years ago

Can you please send me your z.psm1 file? I'd like to try it.

bwets commented 7 years ago

here it is, renamed to .txt z.txt

BTW, I dont seem to have this issue in elevated ps

badmotorfinger commented 7 years ago

Thank you so much for helping me out here. Can you please try the attached file? z.txt

Also can you please provide me with a list of modules which you currently have loaded? You can get this by running Get-Module

bwets commented 7 years ago

nope, still not ok

ModuleType Version Name ExportedCommands


Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con... Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...} Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS... Script 1.1.9 z {cdX, popdX, pushdX, z}

badmotorfinger commented 7 years ago

Also you said this happened recently, was this previously working?

bwets commented 7 years ago

yes it was working like a week ago

badmotorfinger commented 7 years ago

One last request, would it at all be possible to send me your .cdHistory file? If that's too sensitive then I'll need to try another approach.

I've also attached a ps1 file which you can load up in PowerShell ISE and run. It will try to CD into C:\Windows. Hopefully it will tell you the line it's failing at.

z.ps1.txt

bwets commented 7 years ago

ok, I see that the exception happens when saving the history My jump-location is huge, because it has detected all subfolders from a git root It is like 600k and is being written constantly. I guess you could ignore .git folders when inspecting a folder structure...

bwets commented 7 years ago

ok, forget lat comment, thats an other thing... It is not happening anymore (the exception) and that is since I closed an other instance of ps. Maybe some kind of race situation for saving the history? BTW, my .cdHistory only contained one folder, C:\Work\Sandbox

Anyway, I dont know why it is working again...

badmotorfinger commented 7 years ago

That is bizarre. I usually run multiple PowerShell sessions.

Thank you for taking the time to help me on this.

bwets commented 7 years ago

Well, thank you for trying to fix the problem. I will keep you informed if there is anything new on this.

nzbart commented 6 years ago

This problem is now happening to me. Should I open a new Github issue?

I also don't get this issue in an elevated PS instance.

This is the output of Get-Module:

ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                                    
---------- -------    ----                                ----------------                                                                                                                                                                                                    
Binary     2.0.0.0    Hyper-V                             {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAdapter...}                                                                                                                       
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                                                                                                                  
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                                                                                                                           
Script     0.7.1      posh-git                            {Add-PoshGitToProfile, Add-SshKey, Enable-GitColors, Get-AliasPattern...}                                                                                                                                           
<redacted>
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler...}                                                                                                          
Script     1.1.1      PSVSEnv                             {Set-VS2012, Set-VS2013, Set-VS2015, Set-VS2017...}                                                                                                                                                                 
<redacted>                                                                                                      
Script     1.1.9      z                                   {cdX, popdX, pushdX, z}                                                                                                                                                                                             

Note that I am running on a newly built PC.

badmotorfinger commented 6 years ago

Would it be too much trouble to send me your history file via e-mail? I suspect it's something to do in their.

Also could you tell me which OS and version you are using as well as the language it's running under?

Thanks

nzbart commented 6 years ago

No problem; would I send it to p***e@gmail.com?

I'm running Windows 10.0.16299.309. More info:

PS> $host

Name             : ConsoleHost
Version          : 5.1.16299.251
InstanceId       : b20f45e7-bf9f-4edf-b883-302b4d7f2280
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-NZ
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
badmotorfinger commented 6 years ago

If you could send it to me that would be great.

nzbart commented 6 years ago

Did you receive the file that I sent?

badmotorfinger commented 6 years ago

File received thanks. Looks like there's nothing out of the ordinary going on.

I really don't know what the issue is. Your file is not corrupted in anyway.

I suggest you delete your .cdHistory file and launch a powershell session again. If that doesn't work, you might need to assist me in debugging :)

nzbart commented 6 years ago

Hi @vincpa ,

I deleted the .cdHistory file and opened a new PowerShell window. It appears to be working now. I'll let you know if it stops working again.

Thanks!

badmotorfinger commented 6 years ago

I wonder if this has something to do with file permissions.

Thanks for your time guys.