mermaid-cli icon indicating copy to clipboard operation
mermaid-cli copied to clipboard

Error: net::ERR_ACCESS_DENIED on /@mermaid-js/mermaid-cli/dist/index.html

Open qzhuyan opened this issue 1 year ago • 2 comments

Describe the bug just run simple example code give me error as following:

Error: net::ERR_ACCESS_DENIED at file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html

but the file has the right permissions (cat file also works), suspect the error code is miss translated.

ls -alt /home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html
-rw-rw-r-- 1 ubuntu docker 5757725 Feb  1 09:38 /home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html

To Reproduce

Steps to reproduce the behavior:

  1. fresh install npm install -g @mermaid-js/mermaid-cli

  2. then run

cat << EOF  | mmdc --input -
    graph TD
    A[Client] --> B[Load Balancer]
EOF
Generating single mermaid chart

Error: net::ERR_ACCESS_DENIED at file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html
    at navigate (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:215:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Frame.goto (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:181:21)
    at async CDPPage.goto (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js:435:16)
    at async renderMermaid (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:242:5)
    at async parseMMD (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:218:20)
    at async run (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:479:20)
    at async cli (file:///home/ubuntu/.asdf/installs/nodejs/21.6.0/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:184:3)

Expected behavior Should success and no error

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: ubuntu22.04 (ARM64)
uname -a
Linux dev 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:29:11 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

  • Browser: chromium installed with
apt install chromium-browser chromium-codecs-ffmpeg
  • Version [e.g. 22]
mmdc --version
10.7.0

Additional context node version:

node -v
v21.6.0

qzhuyan avatar Feb 01 '24 11:02 qzhuyan

I can't install either

npm install -g @mermaid-js/mermaid-cli
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/@mermaid-js%2fmermaid-cli failed, reason: connect ETIMEDOUT 2606:4700::6810:1b22:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config

node -v v18.18.0

jmruiza avatar May 30 '24 00:05 jmruiza

@jmruiza, it seems like your issue is unrelated.

Can you access https://registry.npmjs.org/@mermaid-js%2fmermaid-cli in your browser?

It seems like you might have internet connectivity issues with npm. It might be worth looking at https://github.com/npm/npm/issues/17064 or https://stackoverflow.com/q/28722515 for tips on how to fix it.

aloisklink avatar Jun 01 '24 10:06 aloisklink

Is there any update on how to fix this error? I've spent a few hours following links and trying to figure out what's causing this, without any luck. System is a fresh Ubuntu 24.04.

I don't get any errors installing with "npm install -g @mermaid-js/mermaid-cli". When I try to run a simple conversion, as shown in the top post of this thread, I get the net::ERR_ACCESS_DENIED error.

I've done the following:

  • disabled ipv6 on the system
  • verified there is no proxy configured (npm config delete proxy, npm config delete http-proxy, npm config delete https-proxy)
  • verified the system has no problems accessing https://registry.npmjs.org/@mermaid-js%2fmermaid-cli (using curl and output to file)
  • updated the node version to v22.5.1
  • Checked permissions on the files in ~/.nvm/versions/node/v22.5.1/node_modules

I'm running out of ideas and things to try. This seems way harder to get running than it should be. The specific error I get is:

Error: net::ERR_ACCESS_DENIED at file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html at navigate (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:215:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Frame.goto (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:181:21) at async CDPPage.goto (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js:435:16) at async renderMermaid (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:251:5) at async parseMMD (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:227:20) at async run (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:491:20) at async cli (file:///home/anewsome/.nvm/versions/node/v22.5.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:192:3

aaronnewsome avatar Jul 22 '24 20:07 aaronnewsome

I found the root cause and fix.

I get kernel print out from dmesg

...  apparmor="DENIED" operation="open" profile="snap.chromium.chromium" ...

So it is the apparmor manages the permissions.

After I append a rule to allow access @{HOME}/.asdf/installs/nodejs/ in the file /var/lib/snapd/apparmor/profiles/snap.chromium.chromium

like

# Layout path: /usr/share/xml/iso-codes
"/usr/share/xml/iso-codes{,/**}" mrwklix,
owner @{HOME}/.asdf/installs/nodejs/** r,
}

then reload it with command

sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.chromium.chromium

then it works

cat << EOF  | mmdc --input -
    graph TD
    A[Client] --> B[Load Balancer]
EOF
Generating single mermaid chart

qzhuyan avatar Aug 06 '24 11:08 qzhuyan