Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined error if nginx is not installed #260

Closed
2 tasks
kirrg001 opened this issue Jul 3, 2017 · 6 comments · Fixed by #266
Closed
2 tasks

Undefined error if nginx is not installed #260

kirrg001 opened this issue Jul 3, 2017 · 6 comments · Fixed by #266
Assignees
Labels
Milestone

Comments

@kirrg001
Copy link
Contributor

kirrg001 commented Jul 3, 2017

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

@kirrg001 kirrg001 added the bug label Jul 3, 2017
@kirrg001 kirrg001 added this to the 1.0.0-rc.1 milestone Jul 3, 2017
@acburdine
Copy link
Member

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

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jul 4, 2017

@acburdine The setup checks for nginx/system can be removed anyway or? They are getting handled in the extensions.

@acburdine
Copy link
Member

No - I think the setup checks still need to be there as it provides a unified way to check if the system stack is met. Just need to fix the error handling 😄

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jul 4, 2017

Ok 👍

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jul 4, 2017

I've pulled latest master, this is not resolved. The error is wrapped into a ListrError instance.

✔ Configuring Ghost
☲ Running setup checks > 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: nginx is not installed
         at execa.shell.catch (/root/ghost-cli/lib/commands/doctor/checks/setup.js:34:53)
         at process._tickCallback (internal/process/next_tick.js:109:7) context: {}, options: [Object] } ],
  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 } }
✖ Running setup checks
A ProcessError occured.

Error occurred running command: 'undefined'

@kirrg001 kirrg001 reopened this Jul 4, 2017
@acburdine
Copy link
Member

ah crap, forgot about that 😕

acburdine added a commit that referenced this issue Jul 4, 2017
closes #260
- fixes error handling to be actually fixed this time
acburdine added a commit that referenced this issue Jul 4, 2017
closes #260
- fixes error handling to be actually fixed this time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants