I have a rule that instructs the chat agent to run certain bash commands. When the agent does there are errors appearing:
$ <. script to run 1>
<some output from my script so it looks like it succeeded>
environment: line 2233: /usr/bin/tr: Argument list too long
environment: line 2233: /usr/bin/base64: Argument list too long
$ <script to run 2>
--: eval: line 22: unexpected EOF while looking for matching `)'
--: eval: line 23: syntax error: unexpected end of file
--: line 1: dump_bash_state: command not found
Steps to Reproduce
Have a rule that says to run some scripts that are in the workspace and then tell the chat agent to run them.
To clarify on OS: Iām running Cursor on Windows but using ssh remote dev into Linux (ubuntu).
Expected Behavior
No errors and the chat agent is able to continue. As it is, it sees the error and so tries workaround.
Operating System
Windows 10/11
Linux
Current Cursor Version (Menu ā About Cursor ā Copy)
Hey, thanks for the report. That makes sense - the source or . command is probably causing issues with how Cursorās terminal state management works. When you source scripts, it can interfere with the internal dump_bash_state function that tracks terminal state between commands.
A few things to try:
Instead of sourcing in your rules, try having the agent run the script directly with bash scripts/something.sh or make it executable and run ./scripts/something.sh
If you need the scriptās environment changes to persist, you could modify your script to export variables explicitly rather than relying on sourcing
The āArgument list too longā errors suggest the state dump is getting too large, which often happens when sourcing scripts that set lots of environment variables.
This is definitely a known issue that the team is working on - you can see similar reports in the threads you linked.
Thank you for the reply. Prior to sourcing it like this, I was using it as an āinit-file in terminal.integrated.profiles.linux so it would setup the environment. But I removed it from there because I was trying to find ways to get the terminal to stop hanging. The terminal hanging issue happens quite often and is rather frustrating.
I canāt just run them as bash scripts as you suggest because then it wonāt persist the environment. They have to be sourced in order to modify the environment of the parent shell. I could have the agent call it as part of every command which is also what I was doing previously, but again⦠I went away from that trying to find ways to avoid the hanging terminal issue.
FYI: itās not setting many environment variables. printenv | wc -c at the end of the script indicates only ~3000 characters.
source $CMD causes problems but source <(${CMD}) doesnāt, so that could be useful. However, it seems that each terminal command might be a separate env so⦠not sure this would work anyway. I need each chat session to have a unique id, but it seems there is no consistent way to interact with the shell because you might get a new one. So, Iāll have to provide an id to the agent require it to remember.