Exception Invoking Fish Shell From Powershell

by ADMIN 46 views

Introduction

In this article, we will delve into the issue of invoking the Fish shell from PowerShell, which results in an exception. We will analyze the problem, identify the root cause, and provide a solution to resolve the issue.

Prerequisites

Before we begin, ensure that you have the latest released version of PSReadLine installed. You can check the version by running the command Get-Module -ListAvailable PSReadLine. Additionally, search the existing issues, especially the pinned issues, to see if a similar problem has been reported.

Exception Report

The exception report is as follows:

PS /Users/roschmac/mount/VM/E/pcut.evolution> /opt/homebrew/bin/fish -c 'ls -la "/Users/roschmac/mount/VM/C/
Program Files (x86)/Embarcadero/Studio/23.0/source/rtl/common/"'
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections
.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

Environment

The environment details are as follows:

PSReadLine: 2.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
PowerShell: 7.5.0
OS: Darwin 24.5.0 Darwin Kernel Version 24.5.0: Thu Apr 10 20:23:06 PDT 2025; root:xnu-11417.120.96.501.2~2/
RELEASE_ARM64_T6041
BufferWidth: 108
BufferHeight: 1

Last 200 Keys:

 F i l e s Spacebar ( x 8 6 ) / E m b a r c a d e r o / S t u d i o / 2 3 . 0 / s o u r c e / r t l / c o m 
m o n / " ' Enter
 / o p t / h o m e b r e w / b i n / f i s h Spacebar - c Spacebar ' s e t Spacebar - U x Spacebar B D S Spa
cebar " / U s e r s / r o s c h m a c / m o u n t / V M / C / P r o g r a m Spacebar F i l e s Spacebar ( x 
PS /Users/roschmac/mount/VM/E/pcut.evolution>                                                               
 t z t Spacebar a u f : Spacebar $ B D S " ' Enter

Exception

The exception details are as follows:

System.InvalidOperationException: Cannot locate the offset in the rendered text that was pointed by the orig
inal cursor. Initial Coord: (46, 17) Buffer: (108, 19) Cursor: (47, 0)
   at Microsoft.PowerShell.PSConsoleReadLine.RecomputeInitialCoords(Boolean isTextBufferUnchanged)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.FRender()
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolea
n ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, 
CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

The command cursor was trying to invoke the following command:

/opt/homebrew/bin/fish -c 'set -Ux BDS "/Users/roschmac/mount/VM/C/Program Files (x86)/Embarcadero/Studio/23.0"; echo "BDS gesetzt auf: $BDS"'

Environment Data

The environment data is as follows:

PS Version: 7.5.0
PS HostName: ConsoleHost
PSReadLine Version: 2.3.6
PSReadLine EditMode: Emacs
OS: Darwin MacBook-Pro-RS.local 24.5.0 Darwin Kernel Version 24.5.0: Thu Apr 10 20:23:06 PDT 2025; root:xnu-11417.120.96.501.2~2/RELEASE_ARM64_T6041 arm64
BufferWidth: 177
BufferHeight: 50

Steps to Reproduce

To reproduce the issue, follow these steps:

  1. Open PowerShell and set the standard shell to Fish.
  2. Use PowerShell to invoke a command with Fish.

Expected Behavior

The expected behavior is that the command should be executed without any exceptions.

Actual Behavior

The actual behavior is that an exception is thrown when trying to invoke the command with Fish.

Solution

To resolve the issue, you can try the following solutions:

  1. Update PSReadLine: Ensure that you have the latest released version of PSReadLine installed.
  2. Disable PSReadLine: Try disabling PSReadLine and see if the issue persists.
  3. Use a different shell: Try using a different shell, such as Bash or Zsh, to see if the issue persists.
  4. Report the issue: Report the issue on GitHub and provide the necessary details.

Q: What is the issue with invoking Fish shell from PowerShell?

A: The issue is that an exception is thrown when trying to invoke a command with Fish from PowerShell. The exception is related to the rendering of the text buffer and the cursor position.

Q: What are the system requirements for this issue?

A: The system requirements for this issue are:

  • PowerShell 7.5.0 or later
  • PSReadLine 2.3.6 or later
  • Fish shell installed on the system

Q: What are the steps to reproduce this issue?

A: To reproduce this issue, follow these steps:

  1. Open PowerShell and set the standard shell to Fish.
  2. Use PowerShell to invoke a command with Fish.

Q: What is the expected behavior when invoking Fish shell from PowerShell?

A: The expected behavior is that the command should be executed without any exceptions.

Q: What is the actual behavior when invoking Fish shell from PowerShell?

A: The actual behavior is that an exception is thrown when trying to invoke the command with Fish.

Q: How can I resolve this issue?

A: To resolve this issue, try the following solutions:

  1. Update PSReadLine: Ensure that you have the latest released version of PSReadLine installed.
  2. Disable PSReadLine: Try disabling PSReadLine and see if the issue persists.
  3. Use a different shell: Try using a different shell, such as Bash or Zsh, to see if the issue persists.
  4. Report the issue: Report the issue on GitHub and provide the necessary details.

Q: What are the possible causes of this issue?

A: The possible causes of this issue are:

  • Incompatible versions of PSReadLine and PowerShell
  • Incorrect configuration of PSReadLine
  • Issues with the Fish shell installation

Q: How can I prevent this issue from occurring in the future?

A: To prevent this issue from occurring in the future, follow these best practices:

  1. Keep PSReadLine and PowerShell up to date: Ensure that you have the latest released versions of PSReadLine and PowerShell installed.
  2. Configure PSReadLine correctly: Configure PSReadLine according to the official documentation.
  3. Use a different shell: Consider using a different shell, such as Bash or Zsh, if you experience issues with Fish.

Q: Where can I find more information about this issue?

A: You can find more information about this issue on GitHub, where the issue is reported. Additionally, you can search for related issues and solutions on the PowerShell and Fish shell communities.