fix: workspace-relative openInEditor paths resolve against cwd and double the package prefix in monorepos
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- nuxtjs, typescript
調査の方向性
Start at the openInEditor entry point described in the issue and inspect how process.cwd(), nuxt.options.workspaceDir, and the existsSync check are used before openInEditorHooks. Reproduce with a pnpm workspace app under apps/web on Windows, then verify that the workspace-relative path opens the expected file and hooks are not blocked by an early failure.
索引モデルが issue の本文から書いたものです。
説明
🐛 The bug
In a pnpm monorepo, Component Inspector → Open in Editor fails with a doubled package path:
File not found: <repo>/apps/web/apps/web/app/features/.../SomeComponent.vue
Expected file:
<repo>/apps/web/app/features/.../SomeComponent.vue
(Same pattern for any package under apps/<name>/, e.g. previously apps/app → apps/app/apps/app/....)
Why
openInEditor resolves non-absolute paths with process.cwd() (the Nuxt package root, e.g. apps/web):
if (input.startsWith("./") || !ABSOLUTE_PATH_RE.test(input))
input = resolve(process.cwd(), input)
The inspector often sends a workspace-relative path like:
apps/web/app/features/.../SomeComponent.vue
So:
cwd (= …/apps/web) + apps/web/app/... → …/apps/web/apps/web/app/...
existsSync then fails and returns before openInEditorHooks run, so hooks cannot fix the path.
Nuxt already exposes nuxt.options.workspaceDir for monorepos, but it is not used here.
🛠️ To reproduce
pnpm monorepo with Nuxt at apps/web → pnpm --filter dev (cwd=apps/web) → Component Inspector → Open in Editor → File not found with doubled apps/web/apps/web/...
🌈 Expected behavior
Resolve relative open-in-editor paths against nuxt.options.workspaceDir (and/or try cwd → rootDir → workspaceDir and pick the first path that exists), then open the file.
Ideally openInEditorHooks should also run (or path normalization should happen) before the hard existsSync failure, so consumers can fix monorepo paths.
ℹ️ Additional context
Detailed reproduction
- pnpm workspace with Nuxt app at
apps/web(not repo root). - Run
pnpm --filter <app> devsoprocess.cwd()isapps/web. - Enable Component Inspector, click a component, Open in Editor.
- Observe
File not found: …/apps/web/apps/web/app/....
Minimal layout:
repo/
pnpm-workspace.yaml # packages: ['apps/*']
apps/
web/ # Nuxt app (cwd when running nuxt dev)
app/
components/
Foo.vue
Environment
- Nuxt:
4.5.x @nuxt/devtools:3.4.x(via Nuxt)- Package manager: pnpm workspace
- OS: Windows 10/11
Workaround
Local Nuxt module wrapping the DevTools RPC openInEditor to rewrite the path (try cwd / rootDir / workspaceDir + undouble apps/<pkg>/apps/<pkg>/…) before calling the original handler.
Also set:
// nuxt.config.ts
workspaceDir: fileURLToPath(new URL('../..', import.meta.url)), // monorepo root
Related
- Possibly related UX issues with inspector → editor: https://github.com/nuxt/devtools/issues/862
- Vite DevTools direction: resolve against
workspaceRootfor open-in-editor
- 主要言語
- TypeScript
- スター
- 3.3k
- フォーク
- 214
- 平均マージ
- 19時間 45分
- マージ済み PR(30日)
- 12
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nuxt/devtools のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
bug needs reproduction
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100