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.

Undefined error if nginx is not installed

See original GitHub issue

I have setup a new droplet without nginx installed.

If i run ghost install, i am getting this error:

✖ Running setup checks
A ProcessError occured.

Error occurred running command: 'undefined'

I debugged quickly, here is the output:

System Stack{ ListrError: Something went wrong
    at ListrError (/root/ghost-cli/node_modules/listr/lib/listr-error.js:4:3)
    at tasks.then (/root/ghost-cli/node_modules/listr/index.js:103:18)
    at process._tickCallback (internal/process/next_tick.js:109:7)
  name: 'ListrError',
  errors:
   [ { Error: Command failed: /bin/sh -c dpkg -l | grep nginx


         at Promise.all.then.arr (/root/ghost-cli/node_modules/execa/index.js:231:11)
         at process._tickCallback (internal/process/next_tick.js:109:7)
       code: 1,
       killed: false,
       stdout: '',
       stderr: '',
       failed: true,
       signal: null,
       cmd: '/bin/sh -c dpkg -l | grep nginx',
       timedOut: false } ],
  context:
   { setup: true,
     ui:
      UI {
        options: [Object],
        stdin: [Object],
        stdout: [Object],
        stderr: [Object],
        verbose: false,
        allowPrompt: true,
        inquirer: [Object],
        spinner: [Object] },
     listr:
      Listr {
        _options: [Object],
        _tasks: [Object],
        concurrency: Infinity,
        _RendererClass: [Function: SilentRenderer],
        exitOnError: false,
        _renderer: SilentRenderer {} },
     linux: true,
     ubuntu: true,
     systemd: true } }

I expect that the CLI tells me that nginx is not installed and skips this extension. The problem here is that dpkg -l | grep nginx returns exit code 1, which results in an error.

We need two things here:

  • somehow handle exit code 1, which is the default exit code of dpkg if a package could not be found (either as a hack in the CLI or push a PR to execa)
  • ensure the error messages shows: “Nginx not installed/found.”

Steps to reproduce:

  1. create a droplet without nginx
  2. run ghost install

successful debugging

I have added a super hack:

            if (!(error instanceof errors.SystemError)) {
                // if nginx is not installed, exit code is 1
                if (error.errors && error.errors.length && error.errors[0].code !== 1) {
                    return Promise.reject(new errors.ProcessError(error));
                } else {
                    error.message = 'Nginx is not installed';
                }
            }

into https://github.com/TryGhost/Ghost-CLI/blob/master/lib/commands/doctor/checks/setup.js#L44, which worked for me.

CLI: latest master

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
acburdinecommented, Jul 3, 2017

oh yeah looking at those checks the error handling is all kinds of crap - will fix it 😄

0reactions
acburdinecommented, Jul 4, 2017

ah crap, forgot about that 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

ubuntu nginx on local machine. Fatal error: Call to undefined ...
As I noticed at my question php-odbc is already installed. Regarding to your advice --with-unixODBC , does it mean that I should reinstall...
Read more >
Help solve the problem during installation (nginx)
I'm not familiar with the UNENCRYPTED_CFG_DIR variable, but it seems to be related to encryption/decription of app configuration and looks like ...
Read more >
Avoiding the Top 10 NGINX Configuration Mistakes
We help you avoid the 10 most common NGINX configuration errors, explaining the problems caused by each and how to fix them.
Read more >
ERROR: Service "nginx-proxy" uses an undefined network ...
Hi, I'm trying to install a production instance on Oracle Cloud for a Linux 7.9 setup, I already installed docker, docker compose and...
Read more >
testing installation and uninstallation of Nginx sometimes ...
Ive installed Nginx then clciked restart Nginx and it works. then ... --no-ask-password” command (process 1898) reported error number 1 when ...
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