TryGhost / Ghost-CLI

CLI Tool for installing & updating Ghost
https://ghost.org
MIT License
450 stars 224 forks source link

Better error handling when system runs out of memory #192

Closed ErisDS closed 3 years ago

ErisDS commented 7 years ago

Trying to run ghost install --no-setup I got this error:

$ ghost install --no-setup $ cat ghost-cli-debug-xxx.log

Debug Information:
    Node Version: v6.10.3
    Ghost-CLI Version: 1.0.0-alpha.16
    Environment: production
    Command: 'ghost install --no-setup'
An error occurred.
Message: 'Command failed: yarn install --no-emoji --no-progress
yarn install v0.21.3
[1/4] Resolving packages...
[2/4] Fetching packages...
'

Stack: Error: Command failed: yarn install --no-emoji --no-progress
yarn install v0.21.3
[1/4] Resolving packages...
[2/4] Fetching packages...

    at Promise.all.then.arr (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:210:11)
    at process._tickCallback (internal/process/next_tick.js:109:7)

Not sure what caused this?

Trying to run the installer again results in:

$ ghost install --no-setup

A SystemError occured.

Message: Current directory is not empty, Ghost cannot be installed here.

Debug Information:
    Node Version: v6.10.3
    Ghost-CLI Version: 1.0.0-alpha.16
    Environment: production
    Command: 'ghost install --no-setup'

I understand why this is, but it's not very helpful 😁 - if the installer fails, I should be able to try again I think?

First issue is something I want to get to the bottom of, clean re-installs is something for later.

acburdine commented 7 years ago

@ErisDS It looks like something got screwed up with yarn. Have you been able to reproduce this multiple times?

ErisDS commented 7 years ago

I was running the command on a droplet I provisioned. No amount of rerunning it sorted the problem. Not sure what else to do to reproduce.

acburdine commented 7 years ago

No amount of rerunning it sorted the problem.

Just to make sure I understand what you're saying - you tried running it in a different folder and it gave the same error?

ErisDS commented 7 years ago

I cleared out the folder, but yes got the same error. I've since destroyed the droplet I think, sorry.

acburdine commented 7 years ago

Hmm...well based on the error shown I'm 99% sure this is something do with yarn. I'll try testing on a droplet at somepoint today, but if I can't reproduce it there my feeling is to wait and see if it happens again or if anyone else reports it?

ErisDS commented 7 years ago

Yeah I'll try and reproduce again as well. I realise it's a bit of a crappy report!

acburdine commented 7 years ago

@ErisDS @chanssl (from the closed duplicate issue): would you both mind trying to reproduce this issue with ghost-cli alpha.18?

I don't know if I've necessarily fixed the issue, but I fixed the error handling so if this particular error does happen again, it will be reported better by the CLI.

Thanks!

chanssl commented 7 years ago

@acburdine Thank you. Look like my system was running out of memory. I will try again after I upgrade the vps .

update : It can be successfully installed after I configured the swap. thanks

dd if=/dev/zero of=/var/swap bs=1k count=1024k mkswap /var/swap swapon /var/swap echo '/var/swap swap swap default 0 0' >> /etc/fstab

tmack8001 commented 7 years ago

I'm getting this exact same experience even on 1.0.0.alpha-19. My installation of ghost 1.0 in on a raspberrypi 3 (understood not a supported platform), which has been running my ghost pre-1.0 installation for a while with no problems.

Here is the related logs I see with the issue highlighting the problems faced (was also a similar or exact same problem on 1.0.0.alpha-18). Below is logs from --verbose as the logs from non verbose weren't very useful.

[04:05:32] Installing dependencies [started]
[04:05:34] → yarn install v0.24.5

[04:05:39] → [1/4] Resolving packages...

[04:05:45] → [2/4] Fetching packages...

[04:05:54] → info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

[04:05:54] Installing dependencies [failed]
[04:05:54] → Command failed: yarn install --no-emoji --no-progress
error Error parsing JSON at "/home/pi/.cache/yarn/v1/npm-ajv-4.11.7-8655a5d86d0824985cc471a1d913fb6729a0ec48/package.json", "/home/pi/.cache/yarn/v1/npm-ajv-4.11.7-8655a5d86d0824985cc471a1d913fb6729a0ec48/package.json: Unexpected token � in JSON at position 0".

yarn install v0.24.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

[04:05:54] Downloading and installing Ghost v1.0.0-beta.1 [failed]
[04:05:54] → Command failed: yarn install --no-emoji --no-progress
error Error parsing JSON at "/home/pi/.cache/yarn/v1/npm-ajv-4.11.7-8655a5d86d0824985cc471a1d913fb6729a0ec48/package.json", "/home/pi/.cache/yarn/v1/npm-ajv-4.11.7-8655a5d86d0824985cc471a1d913fb6729a0ec48/package.json: Unexpected token � in JSON at position 0".

yarn install v0.24.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

A ProcessError occured.

Error occurred running command: 'yarn install --no-emoji --no-progress'

Exit code: 1

Also the versions of various software being used is below:

Debug Information:
    Node Version: v6.11.0
    Ghost-CLI Version: 1.0.0-alpha.19
    Environment: production
    Command: 'ghost install --no-stack --verbose'
$ yarn --version
0.24.6
evilpilaf commented 7 years ago

I'm also having the same issue when attempting to create a new blog with the cli

[?25l[19:26:35] Checking for latest Ghost version [started]
[19:26:38] Checking for latest Ghost version [completed]
[19:26:38] Running system checks [started]
[19:26:38] Checking system node version [started]
[19:26:38] Checking current folder permissions [started]
[19:26:38] Checking system node version [completed]
[19:26:38] Checking current folder permissions [completed]
[19:26:38] Running system checks [completed]
[19:26:38] Setting up install directory [started]
[19:26:38] Setting up install directory [completed]
[19:26:38] Downloading and installing Ghost [started]
[19:26:38] Downloading and installing Ghost v1.0.0-beta.2 [title changed]
[19:26:38] Getting download information [started]
[19:26:40] Getting download information [completed]
[19:26:40] Downloading [started]
[19:26:46] Downloading [completed]
[19:26:46] Installing dependencies [started]
[19:26:47] → yarn install v0.24.5

[19:26:48] → [1/4] Resolving packages...

[19:26:49] → [2/4] Fetching packages...

[19:26:51] → [3/4] Linking dependencies...

[19:27:40] → [4/4] Building fresh packages...

[19:27:45] → Done in 58.23s.

[19:27:45] Installing dependencies [completed]
[19:27:45] Downloading and installing Ghost v1.0.0-beta.2 [completed]
[19:27:45] Moving files [started]
[19:27:45] Summoning Casper [started]
[19:27:45] Linking things [started]
[19:27:45] Linking things [completed]
[19:27:45] Summoning Casper [completed]
[19:27:45] Moving files [completed]
[?25h√ Finishing setup
[?25l[19:27:45] Validating config [started]
[19:27:45] Validating config [completed]
[?25hAn error occurred.
Message: 'The server has encountered an error.'

Stack: InternalServerError: The server has encountered an error.
    at new KnexMigrateError (C:\Users\mauri\AppData\Local\Yarn\config\global\node_modules\knex-migrator\lib\errors.js:7:26)
    at new KnexMigrator (C:\Users\mauri\AppData\Local\Yarn\config\global\node_modules\knex-migrator\lib\index.js:26:15)
    at Listr.run.then (C:\Users\mauri\AppData\Local\Yarn\config\global\node_modules\ghost-cli\lib\commands\start.js:39:28)

Error: Your content path does not exist! Please double check `paths.contentPath` in your custom config file e.g. config.production.json.
    at doesContentPathExist (c:\dv\myOtherBlog\versions\1.0.0-beta.2\core\server\config\utils.js:78:15)
    at Object.loadNconf (c:\dv\myOtherBlog\versions\1.0.0-beta.2\core\server\config\index.js:61:11)
    at Object.<anonymous> (c:\dv\myOtherBlog\versions\1.0.0-beta.2\core\server\config\index.js:78:27)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (c:\dv\myOtherBlog\versions\1.0.0-beta.2\MigratorConfig.js:1:76)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Debug Information:
    Node Version: v6.9.5
    Ghost-CLI Version: 1.0.0-alpha.19
    Environment: development
    Command: 'ghost install local --verbose'
[?25h
acburdine commented 7 years ago

@evilpilaf your error is actually a different one - it's the same as being reported in #228

acburdine commented 7 years ago

My thought is that this problem was originally related to an out-of-memory issue. The error handling around this has been fixed, so I'm going to go ahead and close this. If this does turn out to be something other than an out-of-memory issue then we can either reopen this issue or create a new one 😄

tmack8001 commented 7 years ago

Austin I was still getting this and the error handling didn't lead me to believe anything was OOM, how did error handling change? I'm confused...

On Jun 27, 2017 6:59 PM, "Austin Burdine" notifications@github.com wrote:

My thought is that this problem was originally related to an out-of-memory issue. The error handling around this has been fixed, so I'm going to go ahead and close this. If this does turn out to be something other than an out-of-memory issue then we can either reopen this issue or create a new one 😄

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TryGhost/Ghost-CLI/issues/192#issuecomment-311436922, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDwI5vEUN6T5eiXcZdYNwqhQ5073toDks5sIULkgaJpZM4NPbW5 .

acburdine commented 7 years ago

@tmack8001 can you post your ghost-cli-debug-<timestamp>.log file? That will contain some more contextual info as to why Yarn is exiting.

kirrg001 commented 7 years ago

Happened for me on ghost install local.

A ProcessError occured.

Error occurred running command: 'yarn install --no-emoji --no-progress'

Exit code: 1

Debug Information:
    Node Version: v6.10.3
    Ghost-CLI Version: 1.0.0-beta.3
    Environment: development
    Command: 'ghost install local'

Additional log info available in: /root/.ghost/logs/ghost-cli-debug-2017-07-05T10_08_17_269Z.log
root@dev-kate-01:~/tests/2# cat  /root/.ghost/logs/ghost-cli-debug-2017-07-05T10_08_17_269Z.log
Debug Information:
    Node Version: v6.10.3
    Ghost-CLI Version: 1.0.0-beta.3
    Environment: development
    Command: 'ghost install local'
Error occurred running command: 'yarn install --no-emoji --no-progress'

Exit code: 1

--------------- stdout ---------------
yarn install v0.24.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info This module is OPTIONAL, you can safely ignore this error
info If you think this is a bug, please open a bug report with the information provided in "/root/tests/2/versions/1.0.0-beta.2/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

--------------- stderr ---------------
warning Error running install script for optional dependency: "/root/tests/2/versions/1.0.0-beta.2/node_modules/dtrace-provider: spawn ENOMEM"
error An unexpected error occurred: "/root/tests/2/versions/1.0.0-beta.2/node_modules/jsonpath: spawn ENOMEM".
acburdine commented 7 years ago

@kirrg001 that looks like an out of memory exception.

kirrg001 commented 7 years ago

@acburdine Yes. Can we improve the output?

tmack8001 commented 7 years ago

I'm on holiday without access to my raspberry pi which I was having issues on. I'll check in after my holiday is finished.

On Jul 5, 2017 11:13 AM, "Katharina Irrgang" notifications@github.com wrote:

@acburdine https://github.com/acburdine Yes. Can we improve the output?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TryGhost/Ghost-CLI/issues/192#issuecomment-313061887, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDwIyfOCxv-RjYXjpbAi0BRUHFJjSw3ks5sK2HDgaJpZM4NPbW5 .

arvindvenkataramani commented 7 years ago

Definitely an out of memory exception (Ubuntu 16.04.2 with node 6.11.1 installing Ghost 1 RC); I have 512M on a droplet – adding a 1G swap file fixed it.

francescomugnai commented 7 years ago

I'm getting the same error message but i'm on Win 10 (surface laptop) using ghost-cli version 1.0.3 Is there an easy way to fix it? Thanks!

tmack8001 commented 7 years ago

Here is the contents of my error log.

$ more /home/pi/.ghost/logs/ghost-cli-debug-2017-08-02T03_52_44_600Z.log
Debug Information:
    Node Version: v6.11.0
    Ghost-CLI Version: 1.0.3
    Environment: production
    Command: 'ghost install'
Error occurred running command: 'yarn install --no-emoji --no-progress'

Exit code: 1

--------------- stdout ---------------
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info If you think this is a bug, please open a bug report with the information p
rovided in "/var/www/ghost/trevor-mack.com/versions/1.3.0/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this
command.

--------------- stderr ---------------
error An unexpected error occurred: "/home/pi/.cache/yarn/v1/npm-ajv-4.11.7-8655
a5d86d0824985cc471a1d913fb6729a0ec48/package.json: Unexpected token � in JSON at
 position 0".

let me know what else might be of help in debugging further down this path

tmack8001 commented 7 years ago

understanding that I'm on a unsupported platform, but I like others have been using my raspberry pi for hosting ghost at home for years so would like to see / help get this working with 1.0.x releases again

attempting to install ghost via yarn directly bypassing the ghost-cli gives me the same/similar error

acburdine commented 7 years ago

@tmack8001 your error looks different than the original error for this issue. It looks like something in your Yarn cache might be corrupted. My suggestion is to try clearing your yarn cache (ghost buster is a convenient alias for this 😛 ) and installing again to see if that fixes it.

tmack8001 commented 7 years ago

After going through my running process list and issuing a kill -9 <> on non pertinent stuff that was taking up system memory (xorg, webserver, mysql, python, java, etc) I was able to successfully get a ghost installation and setup completed. Most importantly I believe was xorg, booting straight to command line opened a lot of free memory. Nothing I did ever enabled swap (which is very bad to do on a SD card anyways), but removing programs using majority of memory to open up some helped to resolve the issues faced.

From talking with @acburdine today we believe the above error log I posted was from a follow on installation after a OOM issue with yarn which then had a corrupted / invalid cached file under the ~/.cache/yarn directory. I had seen this on multiple different npm modules, but the error messages looked like the above. If I ever run into failures in the future I'll try and post here or in another issue depending on cause.

francescomugnai commented 7 years ago

I can confirm that the command 'yarn cache clean' solved the problem. Now it works like a charm. Thanks

Nopzen commented 6 years ago

can confirm OP was mem issue for me, I was running a Droplet 512mb ram, resized it and it seemed to make it work.

kevmille commented 3 years ago

yarn cache clean

@francescomugnai: You are a godsend. I was trying to install Ghost 4.3.2 on my Ubuntu 20.04 instance at DigitalOcean. I kept getting the same A ProcessError occurred messages. Spent nearly a day searching DuckDuckGo and Google for the answer. $yarn cache clean did it for me and I was able to install Ghost, finally.

Thanks for this. I think many guys/gals will thank you for this. This should be be included in the Troubleshoot area of Ghost.

github-actions[bot] commented 3 years ago

Our bot has automatically marked this issue as stale because there has not been any activity here in some time. The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR. We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂