Fixing Cursor Composer Agent Not Using the Current venv
Fixing Cursor Composer Agent Not Using the Current venv
If you’ve run into this frustrating bug in Cursor — where the Composer Agent ignores your active Python virtual environment — you’re not alone.
You open a terminal in Cursor, activate your venv, and everything looks good. But when Cursor’s AI tries to run a command, it spawns a fresh terminal that doesn’t respect your venv. Suddenly, packages are missing and commands break.
Why this happens
Cursor uses its own integrated terminal profiles.
If it defaults to a different shell (like
zshwhen you usefish), yourvenv/bin/activatescript may not run correctly.The AI agent executes commands in that “wrong” shell, so your venv context is lost.
The Fix: Set Your Default Shell in Cursor
You can force Cursor to always use the correct shell by editing your User Settings (JSON).
Open Command Palette → Preferences: Open User Settings (JSON) and add:
Linux / macOS
For fish
"terminal.integrated.defaultProfile.linux": "fish",
"terminal.integrated.profiles": {
"fish": { "path": "/usr/bin/fish" }
}
For zsh
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles": {
"zsh": { "path": "/usr/bin/zsh" }
}
For bash
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles": {
"bash": { "path": "/usr/bin/bash" }
}
Windows
If you’re on Windows, Cursor defaults to PowerShell or Command Prompt. You can override that:
For PowerShell
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles": {
"PowerShell": {
"path": "C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe"
}
}
For Command Prompt
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.profiles": {
"Command Prompt": {
"path": "C:\\\\Windows\\\\System32\\\\cmd.exe"
}
}
For WSL
"terminal.integrated.defaultProfile.windows": "Ubuntu-20.04",
"terminal.integrated.profiles": {
"Ubuntu-20.04": {
"path": "wsl.exe",
"args": ["-d", "Ubuntu-20.04"]
}
}
Why this works
Cursor terminals and Composer agent now start in the same shell you actually use.
When you activate a venv, the activation script matches your shell type.
Composer’s commands inherit the correct
$VIRTUAL_ENV(Linux/macOS) or%VIRTUAL_ENV%(Windows) and$PATH.No more “missing module” errors just because the AI ignored your environment.
Bonus Tip
If you often switch projects, consider:
direnvfor auto-activation of venvs, orAdding a small snippet in your shell config to auto-activate when you
cdinto a project.
This ensures that whenever Cursor (or you) enter a directory with a venv, it activates automatically.
✅ After this change, Cursor’s Composer Agent will finally respect your Python venvs — and your AI workflow won’t break in the middle of coding.

