rome / tools

Unified developer tools for JavaScript, TypeScript, and the web
https://docs.rome.tools/
MIT License
23.83k stars 666 forks source link

πŸ› Multiworkspace setup: VSCode extension can't find rome.json #3538

Open gudleik opened 1 year ago

gudleik commented 1 year ago

Environment information

From About VSCode:

Version: 1.72.2
Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:15:55.763Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 22.1.0
Sandboxed: No

Rome VSCode extension: v0.17.20221028

What happened?

Monorepo structure

apps/
  frontend/
  backend/
packages/
  pkg-a/
  pkg-b/
package.json
rome.json

Rome can't detect rome.json as it only looks for the file in apps/ or packages/. From rome server log:

β”œβ”€41780092ms INFO rome_lsp::server Attempting to load the configuration from 'rome.json' file
β”œβ”€41780092ms INFO rome_service::configuration Attempting to load the configuration file at path "/Users/gudleik/code/monorepo/apps/rome.json"
β”œβ”€41780092ms ERROR rome_service::configuration Could not find the file configuration at "/Users/gudleik/code/monorepo/apps/rome.json"

Symlinking rome.json into apps and packages seems to work.

Expected result

Rome should be able to find the rome.json from the workspace root

Code of Conduct

MichaReiser commented 1 year ago

Thanks for reporting this issue.

What folder did you open in VS Code? The mono repo folder, apps or packages?

gudleik commented 1 year ago

We open vscode using a vscode workspace config file from the workspace root: code ./project.code-workspace.

MichaReiser commented 1 year ago

We open vscode using a vscode workspace config file from the workspace root: code ./project.code-workspace.

I'm having difficulties understanding the setup. Are you referring to this VS Code functionality?

Is the Monorepo structure that you shared the structure on the filesystem or what you configured in VS Code?

Would it possible for you to share the VS Code workspace configuration with us?

gudleik commented 1 year ago

I'm having difficulties understanding the setup. Are you referring to this VS Code functionality?

Yes. Rome seems to work fine when starting without using the workspace config, ie code . (where . is the project root).

Our workspace config has this configuration:

{
  "folders": [
    {
      "name": "apps",
      "path": "apps"
    },
    {
      "name": "packages",
      "path": "packages"
    },
    {
      "name": "tests",
      "path": "tests"
    },
    {
      "name": "devops",
      "path": "devops"
    },
    {
      "name": "root",
      "path": "."
    }
  ]
}

If I re-arrange the folders and put root on top, rome finds rome.json and everything works fine.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 14 days with no activity.

woifes commented 1 year ago

The suggested workaround does not work on my side. VSCodium 1.76.0 Release 23062. My projectstructure is simular to the one in the original post. Except that I have a .vsode directory in the root where the workspace definiton lies. Moving the definiton to the root does not resolve the issue.

ematipico commented 1 year ago

The next version of Rome will auto discover the configuration file automatically, that will solve the issue

GabenGar commented 1 year ago

The extension doesn't seem to pick on multi-root workspaces. I have a setup like this:

project
  - rome.json
  - project.workspace
  /backend
    - rome.json
  /frontend

With workspace file:

{
  "folders": [
    {
      "path": ".",
      "name": "project"
    },
    {
      "path": "backend",
      "name": "backend"
    },
    {
      "path": "frontend",
      "name": "frontend"
    }
  ],
}

The project and backend folders have separate installations of rome in their package.json and different configs, but the extension only picks up on the config in project folder even if I browse the code in the backend. The CLI calls do respect their related configs and this creates a situation where I get nagged about errors in IDE when the CLI tool doesn't.

ematipico commented 1 year ago

Thank you for the feedback. The extension is not ready yet to support multiple projects inside a workspace.

That will be solved once Rome will have this awareness