Skip to content

Node compat: process.argv[0] does not use execPath #28889

@Seally

Description

@Seally

Version: Deno 2.2.9

I noticed this while I was digging into why Deno.execPath() and process.execPath ask for permissions, but process.argv[0] and process.argv0 do not.

The Node documentation for process.argv states that:

The process.argv property returns an array containing the command-line arguments passed when the Node.js process was launched. The first element will be process.execPath. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command-line arguments.

The differences can be seen when running:

Deno:

$ bash -c 'exec -a customArgv0 deno repl'
Deno 2.2.9
exit using ctrl+d, ctrl+c, or close()
> process.argv[0]
"customArgv0"
> process.argv0
"customArgv0"

Node:

$ bash -c 'exec -a customArgv0 node'
Welcome to Node.js v23.11.0.
Type ".help" for more information.
> process.argv[0]
'/home/anonymous/.nvm/versions/node/v23.11.0/bin/node'
> process.argv0
'customArgv0'

Of course, fixing this would mean that accessing process.argv[0] would now require read permissions. process.argv on its own probably won't until the getter is called.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions