daisy / ace

Ace by DAISY, an Accessibility Checker for EPUB
MIT License
75 stars 22 forks source link

Installation as super-user fails, after workaround logging directory is missing #361

Open bitsgalore opened 2 years ago

bitsgalore commented 2 years ago

As per the documentation, I installed Ace using (using sudo because earlier attempt at installing with default permissions failed):

sudo npm install @daisy/ace -g -unsafe-perm=true --allow-root

This resulted in:

sudo: npm: command not found

Which is strange, because npm works without sudo. A quick Google search on the error message led me here. I didn't want to mess with file permissions (which is one of the most popular suggestions in that thread), so instead I followed this suggestion. First I queried the location of npm using:

which npm

Result:

/home/johan/.nvm/versions/node/v10.11.0/bin/npm

I then created a symbolic link to this in /usr/bin:

sudo ln -s /home/johan/.nvm/versions/node/v10.11.0/bin/npm /usr/bin/npm

After this change I was able to run the install command without errors. However, after installation, running Ace on an EPUB now failed with the following error message:

(node:6038) ExperimentalWarning: The fs.promises API is experimental
Error: ENOENT: no such file or directory, mkdir '/home/johan/.local/state/DAISY Ace'
    at Object.mkdirSync (fs.js:731:3)
    at File._createLogDirIfNotExist (/usr/lib/node_modules/@daisy/ace/node_modules/winston/lib/winston/transports/file.js:691:10)
    at new File (/usr/lib/node_modules/@daisy/ace/node_modules/winston/lib/winston/transports/file.js:92:28)
    at Object.initLogger (/usr/lib/node_modules/@daisy/ace/node_modules/@daisy/ace-logger/lib/index.js:111:25)
    at Object.run (/usr/lib/node_modules/@daisy/ace/node_modules/@daisy/ace-cli-shared/lib/index.js:98:10)
    at Object.run (/usr/lib/node_modules/@daisy/ace/node_modules/@daisy/ace-cli/lib/index.js:7:13)
    at /usr/lib/node_modules/@daisy/ace/node_modules/@daisy/ace-cli/bin/ace.js:4:29
    at Object.<anonymous> (/usr/lib/node_modules/@daisy/ace/node_modules/@daisy/ace-cli/bin/ace.js:5:3)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

A quick look my '/home/johan/.local/' directory showed that it didn't contain the 'state/DAISY Ace' subdirectories. After creating these directories manually Ace now works as expected.

I have no idea if the missing logging directory is a secondary effect of the symbolic link workaround I used to fix the npm issue, or some (unrelated) bug in Ace. In any case, since the problem with running npm with sudo permissions seems to be widespread, perhaps it would be helpful to add this information to the Troubleshooting page?