Psreadline: Can't run powershell.exe from within a Bash/WSL session

Created on 16 Dec 2016  Â·  5Comments  Â·  Source: PowerShell/PSReadLine

Cannot run powershell.exe from within a Windows Subsystem for Linux Bash session nor from within a Tmux session!:

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 0 Keys:


Exception:
System.IO.IOException: The handle is invalid.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
   at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()
   at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------

Edge case, I know, but a user asked!

Most helpful comment

Invoking Windows PowerShell.exe from within Linux Bash! :)

$ powershell.exe

All 5 comments

PowerShell Core or Windows PowerShell?

Invoking Windows PowerShell.exe from within Linux Bash! :)

$ powershell.exe
user@hostname:~$ powershell.exe
Unable to translate current working directory. Using C:\Users\user
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\user> Exit
Exit
user@hostname:~$ 

Seems to work for me now 🤷‍♂️

I made a small change in Win10 that effectively disables PSReadLine when input is redirected so this scenario works, but only barely - command line editing is worse than if you run powershell from cmd, e.g. no tab completion.

Eventually PSReadLine will support redirected input, see this issue.

I was able to run PowerShell in WSL but I had to be in a Windows directory. /mnt/c/

Was this page helpful?
0 / 5 - 0 ratings