-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Error running interactive capture on any command. #9
Comments
@ozeron https://github.com/ai-christianson/RA.Aid this is the actual devs repo and he fixed this issue already |
@sosacrazy126 can you link to the bug/issue or git commit in his repo that fixes this bug? I tried pip installing the latest code directly from git, and for some reason it downgraded my version of ra.aid to 0.11. How is it possible that the package on pypi is a newer version than the code in github? I'm still getting the error
|
@ozeron were you able to resolve this issue? |
Hi @ruvnet, thanks for all of your awesome work! I am stuck and not able to try SPRAC due to this error! Can you kindly help. |
Are you on a Mac by chance? I am and I had the same error. Based on my research, it appears that this is because the default BSD-based Since I'm just testing and tinkering at this stage, as a workaround, I downloaded Sparc directly and installed via |
@crscheid what specific change did you make in order to get it to work on your Mac? I agree with you that it should be fixed to work more generally (on BSD and non-BSD), but in order to run it on my own machine, it would be great to know how you got it working! I asked Cursor what it suggested, and here is the suggested code to make it work both on Mac and Linux:
|
Very quick hack. Doesn't even check what system is running. I just needed to do some testing. But here is my code: sparc_cli/proc/interactive.py """
Module for running interactive subprocesses with output capture.
"""
import os
import re
import tempfile
import shlex
import shutil
import subprocess
from typing import List, Tuple
def run_interactive_command(cmd: List[str]) -> Tuple[bytes, int]:
"""
Runs an interactive command with a pseudo-tty, capturing combined output.
Assumptions and constraints:
- We are on a BSD-based system (e.g., macOS) with script available
- `cmd` is a non-empty list where cmd[0] is the executable
- The executable and script are assumed to be on PATH
- If anything is amiss (e.g., command not found), we fail early and cleanly
The output is cleaned to remove ANSI escape sequences and control characters.
Returns:
Tuple of (cleaned_output, return_code)
"""
# Fail early if cmd is empty
if not cmd:
raise ValueError("No command provided.")
# Check that the command exists
if shutil.which(cmd[0]) is None:
raise FileNotFoundError(f"Command '{cmd[0]}' not found in PATH.")
# Create temp files (we'll always clean them up)
output_file = tempfile.NamedTemporaryFile(prefix="output_", delete=False)
retcode_file = tempfile.NamedTemporaryFile(prefix="retcode_", delete=False)
script_file = tempfile.NamedTemporaryFile(prefix="script_", mode='w', delete=False)
output_path = output_file.name
retcode_path = retcode_file.name
script_path = script_file.name
# Close the files so we can use them
output_file.close()
retcode_file.close()
# Create a shell script that will run our command and capture the return code
script_content = f"""#!/bin/sh
{' '.join(shlex.quote(c) for c in cmd)}
echo $? > {shlex.quote(retcode_path)}
"""
with open(script_path, 'w') as f:
f.write(script_content)
os.chmod(script_path, 0o755)
def cleanup():
for path in [output_path, retcode_path, script_path]:
if os.path.exists(path):
os.remove(path)
try:
# Disable pagers by setting environment variables
env = os.environ.copy()
env['GIT_PAGER'] = ''
env['PAGER'] = ''
# Run script with our shell script as the command
# BSD script takes command as positional arguments
subprocess.run(['script', '-q', output_path, script_path], env=env)
# Read and clean the output
with open(output_path, "rb") as f:
output = f.read()
# Clean ANSI escape sequences and control characters
output = re.sub(rb'\x1b\[[0-9;]*[a-zA-Z]', b'', output) # ANSI escape sequences
output = re.sub(rb'[\x00-\x08\x0b\x0c\x0e-\x1f]', b'', output) # Control chars
# Get the return code
with open(retcode_path, "r") as f:
return_code = int(f.read().strip())
except Exception as e:
# If something goes wrong, cleanup and re-raise
cleanup()
raise RuntimeError("Error running interactive capture") from e
finally:
# Ensure files are removed no matter what
cleanup()
return output, return_code |
How are you installing the sparc command line tool to make sure it's using the one you modified and not the wheel downloaded from pypi? Here's what I've done:
|
Also, it's complaining about a legacy version of
|
Describe the bug
I've installed dependencies and run a command in an empty folder.
To Reproduce
Steps to reproduce the behavior:
sparc -m "Write a simple todo app with tailwind in vanila Javascript"
Expected behavior
No errors, app does not report success when it fail.
Screenshots
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: