Skip to content

fix: don't treat inline shell commands containing .json/.yaml as config files - #6181

Open
thelastbackspace wants to merge 1 commit into
Unitech:masterfrom
thelastbackspace:fix/5945-inline-command-config-ext
Open

thelastbackspace wants to merge 1 commit into
Unitech:masterfrom
thelastbackspace:fix/5945-inline-command-config-ext

Conversation

@thelastbackspace

Copy link
Copy Markdown

Fixes #5945

pm2 start 'cd app && uvicorn server:app --log-config log_config.yaml' fails with File ... not found. API.start uses Common.isConfigFile(cmd), which is a substring check on the extension, so any command string that mentions a .json/.yml/.yaml/.config.js file gets sent to _startJson and pm2 tries to read the whole command as a file path.

I didn't want to tighten isConfigFile itself, since it's used in a lot of places (and ecosystem.json5 currently relies on the .json match). Instead start now checks one more thing: if the string has whitespace and doesn't exist as a file (resolved against the API cwd, same as _startJson), it's handled as a script/command like any other quoted command. Config paths with spaces in them still work because they exist on disk.

Added test/programmatic/issue_5945_inline_command_config_ext.mocha.js (registered in test/unit.sh). It starts a .yaml and a .json inline command and also checks that a real config file still goes through _startJson. The first case fails on master with the "not found" error and passes with the change.

@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PM2 start Fails When Command Contains "yaml" Or "json"

2 participants