> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Terminal Execution Exceptions

## Introduction

When using Qoder Agent Mode, terminal execution relies heavily on your local environment and shell configuration. You may encounter issues such as:

* Inability to launch the terminal
* Commands not executing
* No output returned

This topic provides common troubleshooting methods to resolve these issues.

### Common troubleshooting methods

#### Method 1: Configure a supported shell

Qoder supports several shells. Ensure you're using a compatible one.

1. Open Qoder.
2. Press`Cmd + Shift + P` （MacOS）or`Ctrl + Shift + P`(Windows/Linux) to open the Command Palette.
3. Type `Terminal: Select Default Profile` and select it.
4. Choose a supported shell:
   * Linux/macOS: `bash`, `fish`, `pwsh`, `zsh`
   * Windows: `Git Bash`, `pwsh`
5. Completely close and reopen Qoder for changes to take effect.

#### Method 2: Manually install shell integration

If terminal integration still fails, install shell integration manually by adding the appropriate line to your shell’s configuration file.

*  zsh (`~/.zshrc`): 

```shellscript theme={null}
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"
```

* Bash (`~/.bashrc`):

```shellscript theme={null}
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"
```

*  PowerShell (`$Profile`):

```shellscript theme={null}
if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }
```

* Fish (`~/.config/fish/config.fish`):

```shellscript theme={null}
string match -q "$TERM_PROGRAM" "vscode"; and . (code --locate-shell-integration-path fish)
```

After editing the file:

1. Save the changes.
2. Restart Qoder completely.

For other shells, refer to manual shell integration.

### If issues persist

If you still don’t receive terminal output:

* Click the "Terminate Terminal" button to close the current terminal session.
* Run the command again. This refreshes the terminal connection and often resolves transient issues.

### Windows-specific troubleshooting

#### Git Bash

1. Download and install Git for Windows from: [https://git-scm.com/downloads/win](https://git-scm.com/downloads/win).
2. Exit and reopen Qoder.
3. Set “Git Bash” as the default terminal: 

   a. Open the Command Palette.

   b. Run: `Terminal: Select Default Profile` .

   c. Select Git Bash.

#### PowerShell

1. Ensure you’re using PowerShell 7 or later.\
   Check your version:

```powershell theme={null}
$PSVersionTable.PSVersion
```

2. If needed, update PowerShell .
3. By default, PowerShell restricts script execution for security. You may need to adjust the execution policy.

a. Open PowerShell as Administrator:

* Press `Win + X`
* Select Windows PowerShell (Admin) or Windows Terminal (Admin)

b. Check the current policy:

```powershell theme={null}
Get-ExecutionPolicy

# If the output is RemoteSigned, Unrestricted, or Bypass, you probably do not need to change the execution policy. These settings should allow shell integration to work properly.
# If the output is Restricted or AllSigned, you may need to change the policy to enable shell integration.
```

c. Update the  policy for your user:

```powershell theme={null}
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

# This will set the RemoteSigned policy for the current user only, which is safer than changing it system-wide.
```

d. Confirm with `Y` when prompted, then verify:

```powershell theme={null}
Get-ExecutionPolicy
```

e. Restart Qoder and retry.

#### WSL

If using Windows Subsystem for Linux (WSL): 

1. Add the following line to your \~/.bashrc:

```sh theme={null}
. "$(code --locate-shell-integration-path bash)"
```

2. Reload your shell or runsource \~/.bashrc.

3. Retry the terminal command in Qoder.

### Abnormal Terminal Output

**Symptoms:**

* Garbled characters, block symbols
* Escape sequences (e.g., `^[[1m`, `^[[32m`)
* Command output is truncated or formatting is messy.

**Possible Causes:**

Third-party shell personalization configurations, such as Powerlevel10k, Oh My Zsh, or custom Fish themes.

#### Solution 1: Disable Complex Prompts/Themes for Agent Execution (Recommended)

Detect if the Agent is running by checking the `QODER_AGENT` environment variable. If it is active, bypass loading complex themes or prompt configurations during shell startup to avoid conflicts.

**zsh** (`~/.zshrc`):

```bash theme={null}
if [[ -n "$QODER_AGENT" ]]; then
  # Skip theme during Agent execution
else
  [[ -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
fi
```

**Bash** (`~/.bashrc`):

```bash theme={null}
if [[ -n "$QODER_AGENT" ]]; then
  PS1='\u@\h \W \$ '  # Use simple prompt during Agent execution
fi
```

#### Solution 2: Temporarily Disable

Comment out theme-related configurations in your shell config file and restart Qoder to test. If the issue is resolved, re-enable items one by one to locate the conflicting component.

For example, commenting out Powerlevel10k in `~/.zshrc`:

```bash theme={null}
# source /path/to/powerlevel10k/powerlevel10k.zsh-theme
```

***
