Hello I am struggling finding a way to force the terminal used by the agent to activate the virtual environment (.venv) when running any command.
I am using PowerShell terminal in Windows, and when I open a new PowerShell terminal it already activates the virtual environment created for the specific project.
However, this doesn’t happen when Cursor agent write any code. I guess there are specific settings for the terminal profile cursor automatically uses but I cannot find any reference to this.
Does anyone has the same problem? Do you know ■■ to tackle this? I hope adding this piece of information in the cursor rules is not the only way.
Am getting this issue too on macOS. How does Cursor load the shell environment used by the agent? I can see that it is different from the integrated terminal.
I hit this problem as well. The best fix I could find was to create the Cusor rule shown below. I have it saved it to ./.cursor/rules/os-venv.mdc in my workspace.
It has pretty well has fixed the issue for me. Each time I invoke the agent, it makes sure my virtual environment is activated. Since I’m on Windows, I also put in an item saying, “figure out what OS you’re on.” Otherwise it would get into some pretty unproductive loops trying to run Unix commands on Windows.
---
alwaysApply: true
---
- When running commands in a terminal, look at the environment to determine what the operating system is, and use this information to run appropriate terminal commands.
- Always be sure that the Python virtual environment located at ./.venv is activated first.