Cursor has trouble with multi-root workspaces and dont find correct path for implementation of composer code

Problem is pretty simple, i’m using cursor with multi-root worskpace.

Let’s say i’m editing a file in @folder1
Ex: @folder1/src/file.ts

Using composer, it always misses it and creates the full path @folder1/src/file.ts …inside @folder1
So i endup with an new file
@folder1/@folder1/src/file.ts

It’s really annoying and cant find anything on the topic. I’m missing a lot of Cursor features for this reason.
Let me know if you need me to provide more infos.

I finally found a solution:

  • I changed workspace config: instead of @nameofmyorg/nameofmy repo I used something simpler like nameofmyrepo for the name
  • I launched a reindexing (probably this one really did the trick).
    And now its working again!

For those of you coming across this that are using a monorepo setup with a single repository, vscode multi root workspaces and turborepo project structure, the accepted answer was not a sufficient solution.

For me, my initial vscode workspace file looked like this (located at .vscode/default.code-workspace in my repository).

Broken Configuration:

{
  "folders": [
    {
      "path": ".",
      "name": "vscode settings",
    },
    {
      "path": "../apps/app1",
      "name": "apps/app1",
    },
    {
      "path": "../packages/package1",
      "name": "packages/package1",
    },
    etc...
  ],
  "settings": {
    "typescript.tsdk": "root/node_modules/typescript/lib",
  },
}

This however resulted in an issue where my files were being read correctly, but when the composer attempted edits, it would always try to create the file relative to the first directory (in this case my .vscode directory). I realized that a fix for this was to add the first entry of the workspace file as the root of the repository (see below). This unfortunately has the consequence of a bit higher memory usage so it’s more of a hack until cursor team handles multi root workspace indexing.

Fixed configuration:

{
  "folders": [
    {
      "path": "..",
      "name": "root",
    },
    {
      "path": ".",
      "name": "vscode settings",
    },
    {
      "path": "../apps/app1",
      "name": "apps/app1",
    },
    {
      "path": "../packages/package1",
      "name": "packages/package1",
    },
    etc...
  ],
  "settings": {
    "typescript.tsdk": "root/node_modules/typescript/lib",
  },
}
1 Like

I realized that the problem only occur for me when I include files to context from different workspace. It seems that Composer does not know where to do the changes and thus uses the root.

The work around for me is :
Include files in context from only one workspace folder