question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug, Discussion] Invalid parsing of the 'exec' parameter in Windows

See original GitHub issue

Info

  • node -v: v17.3.0
  • nodemon -v: 2.0.15
  • Operating system/terminal environment (powershell, gitshell, etc): Windows (shell not important)
  • Using Docker? N/A
  • Command you ran:
  1. Set the exec parameter in the local configuration file (nodemon.json):
{
    "exec": "/C/Program Files/nodejs/node"
}
  1. Run any node application, e.g.:
nodemon app.j

Expected behaviour

The exec parameter should be parsed and converted to: \C\Program Files\nodejs\node

Actual behaviour

  • The exec parameter is parsed using split(' ') (here) , thus it separates the path and converts it to: \C\Program Files/nodejs/node
  • The application crashes because it attempts to access an invalid path:
The system cannot find the path specified.
[nodemon] app crashed - waiting for file changes before starting...

Steps to reproduce

Create a configuration file (nodemon.json) and set the exec paramter to a path containing blank spaces. (just like the example above)


Summary

I have a few ideas, but both of them have some sort of a downside-

  • Introduce execArr parameter which’ll allow setting an executable with arguments in an array. Downside - will be too similar to the execMap parameter.

  • Split exec parameter to execPath and execArgs. Downside - that would break API.

What do you guys think?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
remycommented, Jul 17, 2022

Just reading this, the arg doesn’t look valid:

"exec": "/C/Program Files/nodejs/node"

Shouldn’t it be:

"exec": "/C/Program\ Files/nodejs/node"

// or

"exec": "'/C/Program Files/nodejs/node'"
0reactions
TheDechevcommented, Aug 17, 2022

You are completely right @remy, my bad, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
[Bug, Discussion] Invalid parsing of the 'exec' parameter in Windows.
Read more >
JDK-4365120 Runtime.exec(String) does not parse ... - Bug ID
JDK-4365120 : Runtime.exec(String) does not parse quotes correctly. Type: Bug; Component: core-libs; Sub-Component: java.lang; Affected Version: 1.2.2,1.3.0.
Read more >
Unable to create database (Oracle 12c R1 12.1.0.1.0 ...
I am installing Oracle 12c R1 on Windows 2012. ... O/S-Error: (OS 87) The parameter is incorrect". ... Parsing command line arguments:.
Read more >
Error parsing the command-line arguments - TeraByte Unlimited
You can proves this by just setting up a run parameter exec testit.exe "testing\" /123. You'll see it's: testing\ /123
Read more >
Solve Problems with External Command Lines in PowerShell
Windows PowerShell exacerbates the problem of command-line argument parsing because Windows PowerShell has its own syntax parser that must ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found