Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

KIRO-IDE command execution bug TY=not a tty

Open NileshjVaghela opened this issue 10 months ago • 13 comments

Before opening, please confirm:

Operating System

linux

Kiro Version

0.8.135

Bug Description

execute_bash tool outputs 'TY=not a tty' causing command failures"

This is misleading KIRO-IDE and all the command executed automatically by KRIO-IDE have this issues. It is consuming my credit without positive output.

--------actual output----- Docker Compose version v5.0.0 TY=not a ttyilesh@nilesh-Inspiron-14-7435-2-in-1: ~/kiro/cost-reportnilesh@nilesh-Inspiron-14-7435-2-in-1:~/kiro/cost-report --------Interpreted by KIRO-IDE------- I see the issue - all commands are returning Exit Code: -1 even though they're working. This appears to be a terminal/TTY issue. Let me check if the containers are actually running:

My all other command in actual terminal work fine. Even KIRO-CLI works fine. But KIRO-IDE is not.

Steps to Reproduce

docker compose version Docker Compose version v5.0.0 TY=not a ttyilesh@nilesh-Inspiron-14-7435-2-in-1: ~/kiro/cost-reportnilesh@nilesh-Inspiron-14-7435-2-in-1:~/kiro/cost-report I see the issue - all commands are returning Exit Code: -1 even though they're working. This appears to be a terminal/TTY issue. Let me check if the containers are actually running:

Expected Behavior

docker compose version Docker Compose version v5.0.0 nilesh@nilesh-Inspiron-14-7435-2-in-1: ~/kiro/cost-reportnilesh@nilesh-Inspiron-14-7435-2-in-1:~/kiro/cost-report I see the issue - all commands are returning Exit Code: -1 even though they're working. This appears to be a terminal/TTY issue. Let me check if the containers are actually running:

Conversation ID

fff05874-2b1a-42df-9370-455c32db1a1d 165b7f17-f1f8-47af-a503-e715c0a314ac 57a544bb-5b42-4897-824e-75e3a622acdf edb035b2-a78f-4699-82ca-70dd88ac1099 bcca0050-3596-493c-8810-c3de349883a1

Additional Context

No response

NileshjVaghela avatar Jan 29 '26 19:01 NileshjVaghela

🤖 Potential Duplicate Detected

This issue appears to be similar to:

What happens next?

  • ⏰ This issue will be automatically closed in 3 days
  • 🏷️ Remove the duplicate label if this is NOT a duplicate
  • 💬 Comment on the original issue if you have additional information

Why is this marked as duplicate? Both report terminal/command execution issues with corrupted output and incorrect exit codes. Issue #4833 specifically mentions 'Terminal tool corrupts output and reports incorrect exit codes when shell outputs OSC escape sequences' which matches the new issue's 'TY=not a tty' terminal corruption and exit code -1 problems.

github-actions[bot] avatar Jan 29 '26 19:01 github-actions[bot]

I experienced the same issue and found a working solution. Sharing my workaround for those who have kiro-cli installed.

Root Cause

The Kiro CLI post block in .bashrc executes kiro-cli init bash post, which outputs unwanted strings and overwrites the exit code when Kiro runs commands.

Solution

Make the Kiro CLI post block conditional at the bottom of .bashrc:

# Kiro CLI post block. Keep at the bottom of this file.
if [[ "$TERM_PROGRAM" != "kiro" ]]; then
    [[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash"
fi

Results

Before:

> ls -la
TY=not a tty2026/01/30_04:13:58  :~/workspace    
[user@host workspace] (main *+)
Exit Code: -1

After:

> ls -la
total 20
drwxr-xr-x.  3 user user    42 Jan 30 04:11 .
drwx------. 21 user user 16384 Jan 30 04:28 ..
-rw-r--r--.  1 user user  1584 Jan 30 04:27 file.txt
Exit Code: 0

This approach uses the TERM_PROGRAM=kiro environment variable that Kiro automatically sets.

tdHiru avatar Jan 30 '26 04:01 tdHiru

This is not working.

On Fri, Jan 30, 2026 at 10:22 AM tdHiru @.***> wrote:

tdHiru left a comment (kirodotdev/Kiro#5240) https://github.com/kirodotdev/Kiro/issues/5240#issuecomment-3821798969

I experienced the same issue and found a working solution. Root Cause

The Kiro CLI post block in .bashrc executes kiro-cli init bash post, which outputs unwanted strings and overwrites the exit code when Kiro runs commands. Solution

Make the Kiro CLI post block conditional at the bottom of .bashrc:

Kiro CLI post block. Keep at the bottom of this file.if [[ "$TERM_PROGRAM" != "kiro" ]]; then

[[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash"fi

Results

Before:

ls -la TY=not a tty2026/01/30_04:13:58 :~/workspace @.*** workspace] (main *+) Exit Code: -1

After:

ls -la total 20 drwxr-xr-x. 3 user user 42 Jan 30 04:11 . drwx------. 21 user user 16384 Jan 30 04:28 .. -rw-r--r--. 1 user user 1584 Jan 30 04:27 file.txt Exit Code: 0

This approach uses the TERM_PROGRAM=kiro environment variable that Kiro automatically sets.

— Reply to this email directly, view it on GitHub https://github.com/kirodotdev/Kiro/issues/5240#issuecomment-3821798969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ2WPER65B6A7JGUXUXCW434JLPRHAVCNFSM6AAAAACTLJEWF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMRRG44TQOJWHE . You are receiving this because you authored the thread.Message ID: @.***>

NileshjVaghela avatar Jan 30 '26 17:01 NileshjVaghela

This issue has been automatically closed as it appears to be a duplicate of an existing issue.

If you believe this is incorrect, please comment on this issue and a maintainer will review it.

github-actions[bot] avatar Feb 02 '26 00:02 github-actions[bot]

This is not working. ...

It worked fine in my environment (amazon linux), so please review your other .bashrc settings.

tdHiru avatar Feb 02 '26 06:02 tdHiru

Kiro CLI post block. Keep at the bottom of this file.

[[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" complete -C "/usr/local/bin/aws_completer" aws

Kiro CLI post block. Keep at the bottom of this file.

if [[ "$TERM_PROGRAM" != "kiro" ]]; then [[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" fi

On Mon, Feb 2, 2026 at 12:30 PM tdHiru @.***> wrote:

tdHiru left a comment (kirodotdev/Kiro#5240)

This is not working. ...

It worked fine in my environment (amazon linux), so please review your other .bashrc settings.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

NileshjVaghela avatar Feb 02 '26 07:02 NileshjVaghela

I am also attaching the screenshot for more clarity.

The extra message " TY=not a tty " appears in KIRO-IDE interactive message chat windows with exit code -1

It is not observerd in any terminal. event within KIRO IDE terminal too.

But becasues of Exit code -1 kiro gives error and deviate to other taks.

On Mon, Feb 2, 2026 at 12:42 PM nilesh vaghela @.***> wrote:

Kiro CLI post block. Keep at the bottom of this file.

[[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" complete -C "/usr/local/bin/aws_completer" aws

Kiro CLI post block. Keep at the bottom of this file.

if [[ "$TERM_PROGRAM" != "kiro" ]]; then [[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" fi

On Mon, Feb 2, 2026 at 12:30 PM tdHiru @.***> wrote:

tdHiru left a comment (kirodotdev/Kiro#5240)

This is not working. ...

It worked fine in my environment (amazon linux), so please review your other .bashrc settings.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

NileshjVaghela avatar Feb 02 '26 07:02 NileshjVaghela

Please find the screenshot.

On Mon, Feb 2, 2026 at 12:46 PM nilesh vaghela @.***> wrote:

I am also attaching the screenshot for more clarity.

The extra message " TY=not a tty " appears in KIRO-IDE interactive message chat windows with exit code -1

It is not observerd in any terminal. event within KIRO IDE terminal too.

But becasues of Exit code -1 kiro gives error and deviate to other taks.

On Mon, Feb 2, 2026 at 12:42 PM nilesh vaghela @.***> wrote:

Kiro CLI post block. Keep at the bottom of this file.

[[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" complete -C "/usr/local/bin/aws_completer" aws

Kiro CLI post block. Keep at the bottom of this file.

if [[ "$TERM_PROGRAM" != "kiro" ]]; then [[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" fi

On Mon, Feb 2, 2026 at 12:30 PM tdHiru @.***> wrote:

tdHiru left a comment (kirodotdev/Kiro#5240)

This is not working. ...

It worked fine in my environment (amazon linux), so please review your other .bashrc settings.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

NileshjVaghela avatar Feb 02 '26 07:02 NileshjVaghela

@tdHiru thanks. I encountered a similar issue which I reported in https://github.com/kirodotdev/Kiro/issues/4011. Your work around worked well for me on mac

Image

rossalanmiller avatar Feb 05 '26 18:02 rossalanmiller

In my case the issue is with only any docker commands. As of now all other command works well.

NileshjVaghela avatar Feb 09 '26 13:02 NileshjVaghela

Thank you for your feedback! 🙏

The duplicate label has been removed and this issue has been sent back for maintainer review.

A maintainer will review this issue shortly.

github-actions[bot] avatar Feb 20 '26 15:02 github-actions[bot]

✅ Confirmed fix on Ubuntu (bash) — detailed explanation + live tests

The workaround from @tdHiru worked for me. Here's a detailed breakdown for anyone experiencing this.

Root Cause

The file ~/.local/share/kiro-cli/shell/bashrc.post.bash contains:

[ -n "$BASH_VERSION" ] && command -v kiro-cli >/dev/null 2>&1 && eval "$(kiro-cli init bash post --rcfile bashrc)"

When Kiro IDE executes commands internally (e.g., from the AI chat agent), it spawns a shell without a real TTY. The kiro-cli init bash post command outputs unwanted strings including the tty command result (not a tty), which corrupts the command output and causes Exit Code: -1.

This does not affect:

  • Kiro CLI (has a real TTY)
  • Kiro IDE's integrated terminal (has a pseudo-TTY)
  • Any regular terminal emulator

It only affects commands executed by the Kiro IDE agent (chat/agentic mode).

Fix

Replace the Kiro CLI post block at the bottom of ~/.bashrc:

Before:

# Kiro CLI post block. Keep at the bottom of this file.
[[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash"

After:

# Kiro CLI post block. Keep at the bottom of this file.
if [[ "$TERM_PROGRAM" != "kiro" ]]; then
  [[ -f "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash" ]] && builtin source "${HOME}/.local/share/kiro-cli/shell/bashrc.post.bash"
fi

⚠️ Important: You must replace the original line, not add the conditional alongside it. @NileshjVaghela reported the fix didn't work, but looking at his comment he had both the original and the conditional version — so the original was still executing and causing the issue.

Bonus: Angular CLI users

If you have source <(ng completion script) in your .bashrc, wrap it with a TTY guard to prevent similar issues:

[ -t 0 ] && source <(ng completion script)

Live tests post-fix

We ran these tests directly from the Kiro IDE agent chat to confirm:

Command Before fix After fix
echo "hola mundo" ❌ Output lost, TY=not a tty, Exit -1 ✅ Exit 0
.venv/bin/python -c "print('test')" ❌ Output lost, Exit -1 ✅ test python — Exit 0
Python stdout + stderr simultaneously ❌ Output lost or Exit -1 ✅ Both streams captured — Exit 0
pip list | head -5 ❌ Blocked ✅ Full output — Exit 0

How we diagnosed it

  1. The literal string not a tty is the output of /usr/bin/tty when stdin is not a terminal
  2. Using subprocess tests, we confirmed no shell config (NVM, pyenv, SDKMAN) was calling tty directly
  3. Inspecting bashrc.post.bash revealed kiro-cli init bash post as the source — it runs tty internally and its output leaks into the command results
  4. The TERM_PROGRAM=kiro env var is set by Kiro IDE, making it a reliable condition to skip the post block

Environment

  • Ubuntu 24.04 LTS
  • Kiro IDE 0.x (latest stable)
  • Kiro CLI (latest)
  • bash 5.2
  • Also had NVM, pyenv, SDKMAN, Angular CLI loaded in .bashrc

dgzraul avatar Apr 15 '26 05:04 dgzraul

Please be aware that kiro updates may overwrite the guard in your .bashrc file, check after every update to confirm that it's still in place.

elchanio-76 avatar May 01 '26 12:05 elchanio-76