For me, the issue was the fact that I use a bare repository with multiple worktrees and Cursor/VSCode was opened on the top level. Opening a worktree specifically in the IDE fixed the problem.