Skip to content

inspector: warn when a file shadows node inspect#64448

Closed
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:inspector/warn-shadowed-inspect
Closed

inspector: warn when a file shadows node inspect#64448
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:inspector/warn-shadowed-inspect

Conversation

@bitpshr

@bitpshr bitpshr commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #64111.

node inspect runs the debugger, so a local inspect.js gets silently shadowed. This emits a warning when a file named after the command exists in the current directory, pointing at how to run it instead (node ./inspect.js).

I went with a warning rather than a hard error, since erroring would break legitimately running the debugger from a directory that happens to contain an inspect.js. Happy to switch to an error if you'd prefer that.

Added a test under test/parallel.

`node inspect` runs the debugger, but if a file named after the command
(for example `inspect.js`) also exists in the current directory, that
file is silently not run. Emit a warning in that case so the shadowing
is visible, pointing at how to run the file instead.

Fixes: nodejs#64111
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
@nodejs-github-bot nodejs-github-bot added debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run. labels Jul 12, 2026
@aduh95

aduh95 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

I really don't think it's worth fixing, there are many other "shadowing" happening (e.g. if you have a file and a directory with the same name, the file shadows the directory and you don't hear anyone complaining about it). It's like a quirk, sure it can be surprising but we don't recommend not providing the file extension, omitting it is asking for trouble

@bitpshr bitpshr closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node inspect hides inspect.js script without warning

3 participants