Exit codes and environment variables
What each exit code means, every variable the CLI reads, and what Fatal: TypeError: fetch failed tells you.
If you run cohostly from a script, two things matter: the number it exits with, and the variables that change how it behaves.
Exit codes
An exit code is a small number a program leaves behind when it stops. 0 means all went well. Anything else means something did not.
0n to the deploy question, and a logs -f follow that the platform ended after 60 minutes.12deploy: the settings needed your confirmation, there was no terminal to ask in, and you used --draft. Nothing was deployed.130secrets set or ai-keys set).127dev: your command could not start. Otherwise dev returns your command's own exit code.Two commands pass on the code of something else:
snapshotandcheckreturn the exit status of the capture tool.types --projectsets the exit code from the result of its check.
Current behaviour: a deploy that is built but held for approval exits 0 when you deploy a folder, and 1 when you deploy from a .cohostly/ folder. See put an app online and deploy what already runs.
Environment variables
API_URLhttps://api.cohostly.cloud.PLATFORM_API_KEYcredentials.json. Meant for CI.PLATFORM_CONFIG_DIRcredentials.json. Default ~/.config/cohostly.PLATFORM_NO_BROWSERopen prints the address without launching a browser.PLATFORM_VERBOSE1 and deploy prints every build line. Same as --verbose.VISUAL, EDITOR[e]dit answer in the deploy question. Default vi (notepad on Windows).COHOSTLY_RAILPACKCOHOSTLY_CAPTUREsnapshot and check. An error if the file does not exist.HOME~/.cohostly/.Good to know The names are exactly
API_URLandPLATFORM_API_KEY. There is noCOHOSTLY_API_KEYand noCOHOSTLY_API_URL.
Fatal: TypeError: fetch failed
You may see this:
Fatal: TypeError: fetch failed at ...
It means the CLI could not reach the platform at all, and the command had no tidy message for that. The cause is nearly always one of these:
- You have no internet connection, or a proxy or firewall blocks it.
API_URLpoints somewhere wrong. Checkecho $API_URL.
It exits with code 1. Fix the connection or the address and run the command again.
Some commands print a clearer line instead, Failed to connect to API at <url>: <message>. These are deploy, versions, promote, rollback, backup, backups, restore, logs, manifest check and ls. The commands that show the Fatal: line are secrets, token, ai-keys, bindings, cost, dev, types, whoami, open, schedules, share, domains, ship and approvals. The cure is the same for both.
Any other uncaught error prints Fatal: <error>, with a stack trace, and exits with 1.
No help flags
--help, -h and --version are not supported. They print Unknown command: <x>, then the command list, and exit with 1. Plain cohostly prints the list and also exits with 1.
Where the CLI keeps files
~/.config/cohostly/credentials.json0600. Moved by PLATFORM_CONFIG_DIR.~/.cohostly/tools/~/.cohostly/keys/pack and snapshot to seal values.