Unitech / Unitech/pm2

'Start' command fails with more than 4 options

Open
#2,064 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T: Bug
Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

When specifying more than 4 options to pm2 start using the -- --optionone 42 --optiontwo aa flag, pm2 fails with the error: which: must specify command. More details below.

This issue was probably introduced with version 1.0.0 as it does not occur on v0.15.9, but does with 1.0.2.

The following command succeeds:
pm2 start starttest.js -- --a z --b y --c x --d w

The following command fails:
pm2 start starttest.js -- --a z --b y --c x --d w --e v

Steps to reproduce:

  1. `echo "console.log(process.argv.slice(2));" >> starttest.js
  2. pm2 start starttest.js -- --a z --b y --c x --d w --e v

Actual:

› pm2 start starttest.js -- --a z --b y --c x --d w --e v 
which: must specify command
[PM2][ERROR] script not found : /current-working-directory/--e
script not found : /current-working-directory/--e
┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

Expected:

› pm2 start starttest.js -- --a z --b y --c x --d w --e v
[PM2] Starting starttest.js in fork_mode (1 instance)
[PM2] Done.
┌───────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐
│ App name  │ id │ mode │ pid   │ status │ restart │ uptime │ memory      │ watching │
├───────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤
│ starttest │ 0  │ fork │ 46454 │ online │ 0       │ 0s     │ 13.504 MB   │ disabled │
└───────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pm2 start command and reproduce the issue using the starttest.js script and the two command examples. Compare handling of four versus five forwarded options, then verify that the five-option invocation starts the script and preserves all arguments without treating --e as a script path.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.