mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.39k stars 227 forks source link

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

Closed qzhuyan closed 1 month ago

qzhuyan commented 8 months ago

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

jmruiza commented 4 months ago

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

aloisklink commented 4 months ago

@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.

aaronnewsome commented 2 months ago

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:

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

qzhuyan commented 1 month ago

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