Ghost-CLI: Ghost-CLI 1.5.2 fails in a loop

A case exists on the problem see #9511. Since it’s closed, I was told to open another one, which I am doing here.

Issue Summary

When proceeding with the standard “ghostuser” account and use “sudo”, on a Debian Stretch Linux (9.4), with NodeJS v8.10.0 installed, I try to install Ghost-CLI v1.5.2, it starts and runs in a loop.

Here are the details below:

Steps to Reproduce

  1. Create a New User
adduser ghostuser
cat /etc/passwd
ghostuser:x:1002:1002:Ghost User,,,:/home/ghostuser:/bin/bash
  1. Super User Privileges
usermod -aG sudo ghostuser
  1. Installation NodeJS v8.10.0 and NPM
ghostuser@host:~$ sudo apt install apt-transport-https
ghostuser@host:~$ curl -sL https://deb.nodesource.com/setup_8.x | bash -
ghostuser@host:~$ sudo apt install -y nodejs
ghostuser@host:~$ sudo apt install -y build-essential
  1. Check NodeJS and NPM versions
ghostuser@host:~$ node -v && npm -v
v8.10.0
5.6.0
  1. Installation Ghost-CLI v1.5.2 (for now the lasted)
ghostuser@host:~$ sudo npm i -g ghost-cli@latest
npm WARN deprecated yarn@1.3.2: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
npm WARN deprecated fs-promise@0.5.0: Use mz or fs-extra^3.0 with Promise Support 
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/ghost-cli/node_modules/dtrace-provider/.node-gyp/8.10.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/ghost-cli/node_modules/dtrace-provider/.node-gyp"
...

Sorry but same issue with ‘sudo’ and need a break ‘Ctrl+C’ to exit this loop.

BUT, really curious, if repeat install Ghost-CLI, this upgrade and done :

ghostuser@host:~$ sudo npm i -g ghost-cli@latest                                                             
[sudo] Mot de passe de ghostuser : 
npm WARN deprecated yarn@1.3.2: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
npm WARN deprecated fs-promise@0.5.0: Use mz or fs-extra^3.0 with Promise Support                            
/usr/bin/ghost -> /usr/lib/node_modules/ghost-cli/bin/ghost                                                  
+ ghost-cli@1.5.2
updated 1 package in 7.703s

Check :

ghostuser@host:~$ ghost version                                                                              
Ghost-CLI version: 1.5.2

I repeated the same test twice and it reproduces the same problem well: first install failed in loop, break this with Ctrl+C and try second install, this indicate rollback then upgrade and done.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (23 by maintainers)

Commits related to this issue

Most upvoted comments

I tested this on Ubuntu and error appeared. This solution worked for me:

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

https://stackoverflow.com/questions/49529696/yarn-error-eaccess-permission-denied-scandir-home-ubuntu-config-yarn-link

here is solution: https://forum.ghost.org/t/an-unexpected-error-occurred-eacces-permission-denied/2834

sudo chown <username>:<username> ~/.config

@cmlanche yup - gonna add that into the CLI here soon.

90% sure this is caused by: https://www.npmjs.com/package/configstore This dependency writes a file into ~/.config. Used by update-notifier dependency. Used here: /lib/utils/update-check.js

The .config folder get’s created during the CLI installation. It will contain a file called update-notifier-npm.json:

{
	"optOut": false,
	"lastUpdateCheck": 1525099880433
}

There must be a postinstall hook somewhere.

So after some deliberation on slack, instead of adding docs to try and work around whatever the issue is in npm/node-gyp, we’re gonna remove the dependency on ghost-ignition in favor of extracting the prettylogger class (which is the only file from ghost-ignition that is used). That way, the dtrace-provider dependency (pulled in by ghost-ignition) won’t be installed.

Gonna close this because this isn’t a CLI issue, and is rather an issue with npm/node-gyp. According to this issue, the fix is to install with sudo npm install -g --unsafe-perm ghost-cli.

There’s not much that I can do to remove the gyp dependency short of removing our dependency on ghost-ignition (which we use for a couple of things).