Skip to content

Fix silent script failure on Windows (Git Bash / MINGW)#320

Open
w3spi5 wants to merge 1 commit intobuildermethods:mainfrom
w3spi5:fix/silent-exit-on-error
Open

Fix silent script failure on Windows (Git Bash / MINGW)#320
w3spi5 wants to merge 1 commit intobuildermethods:mainfrom
w3spi5:fix/silent-exit-on-error

Conversation

@w3spi5
Copy link

@w3spi5 w3spi5 commented Jan 25, 2026

Problem

The installation script silently exits after displaying "Configuration:" when run on Windows with Git Bash / MINGW. No error message is shown, making debugging very difficult.

Root Causes

  1. CRLF line endings: Git on Windows converts files to CRLF by default, which breaks bash scripts
  2. Bash arithmetic exit codes: Expressions like ((count++)) return exit code 1 when the variable is 0 (because 0 is "false" in bash). Combined with set -e, this silently terminates the script

Solution

1. Auto-fix CRLF on Windows

Added detection and automatic conversion of CRLF to LF when running on MINGW/MSYS. The script converts all .sh and .yml files, then restarts itself.

2. Retry mechanism

If the script fails for any reason, it automatically retries without strict mode (set -e), allowing it to complete and show any errors.

3. Safe arithmetic expressions

Added || true to all ((var++)) expressions to prevent them from triggering set -e when the variable is 0.

4. .gitattributes

Added .gitattributes to enforce LF line endings for future clones.

Files Changed

  • scripts/project-install.sh - Added CRLF fix, retry mechanism, and safe arithmetic
  • .gitattributes - New file to enforce LF line endings

Testing

Tested on Windows 11 with Git Bash (MINGW64). Script now completes successfully on first run.

@w3spi5
Copy link
Author

w3spi5 commented Jan 25, 2026

Hi @CasJam,

I noticed PR #317 by @Perlover addresses the same arithmetic exit code issue. Their approach uses pre-increment ((++var)) instead of my ((var++)) || true — both work, but theirs is cleaner.

However, my PR includes additional fixes that #317 doesn't cover:

  1. Auto-fix CRLF on Windows — Detects and converts CRLF to LF automatically when running on Git Bash/MINGW, then restarts the script
  2. Retry mechanism — If the script still fails for any reason, it retries without set -e to allow completion
  3. .gitattributes — Prevents CRLF issues for future clones

These additions specifically address Windows compatibility issues that caused the script to fail silently (see discussion #311).

Suggestion: You could merge #317 first (simpler fix), then cherry-pick my CRLF/retry additions. Or I can update my PR to use ((++var)) instead of || true if you prefer a single merged solution.

Let me know what works best!

@w3spi5
Copy link
Author

w3spi5 commented Feb 2, 2026

@CasJam, have you seen PR on your project ? wake up please, we are waiting for this correction. I have to modify all my dev env on all machines, please correct asap

@w3spi5
Copy link
Author

w3spi5 commented Feb 2, 2026

⚠️ Additional Fix: Permission Denied on Linux/WSL2

If you manually copy the scripts (instead of git clone), you may get "Permission denied" errors when running them.

Root cause: Unix execute permissions (+x) are not preserved when copying files between Windows (NTFS) and Linux/WSL2 filesystems.

Quick fix:
chmod +x ~/agent-os/scripts/*.sh

This fixed my issue on my desktop (WSL2 Ubuntu) where the scripts worked fine on my laptop but failed with "permission denied" on my fixed PC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant