microsoft / microsoft/BitNet

sys.exit(1) runs unconditionally due to indentation bug in run_command()

Open
#447 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
40.3k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

Hi!

I think there's an indentation issue in setup_env.py (line 107) inside the run_command function:

    else:
        try:
            subprocess.run(command, shell=shell, check=True)
        except subprocess.CalledProcessError as e:
            logging.error(f"Error occurred while running command: {e}")
        sys.exit(1)  # this is outside the except block

The sys.exit(1) is at the same indentation as the try, so it runs unconditionally after the subprocess finishes — even when the command succeeds. I believe it was meant to be inside the except block.

The same pattern is in utils/e2e_benchmark.py line 23.

Happy to send a PR to fix the indentation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect run_command() in setup_env.py around line 107 and the matching code in utils/e2e_benchmark.py around line 23. Confirm that successful subprocess.run calls return normally while failures exit with status 1; done means both files have the intended failure-only behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.