mermaidjs / mermaid.cli

Development has been moved to https://github.com/mermaid-js/mermaid-cli
MIT License
1.09k stars 117 forks source link

Unhandled exception when trying to convert mmd file #16

Closed angrykoala closed 6 years ago

angrykoala commented 6 years ago

When executing mmdc -i my_file.mmd with node 6.11.5 in mermaidCLI 0.3.1, the following exception happens:

(node:29742) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES

Same issue when using node 8 and 9

The minimal file I tried:

graph LR
A-->B;
agusmba commented 6 years ago

It seems one of the changes in the last commit https://github.com/mermaidjs/mermaid.cli/commit/1f9a6bce11289f4227d3fb0a93a512690953540d is breaking also the dev version.

I'll try to narrow it down

agusmba commented 6 years ago

In my case it's puppetteer's new version (with new chrome) giving me grief.

agusmba commented 6 years ago

In windows, the problem seems to be with my antivirus, for some reason it won't let me execute chrome when I use puppeteer 0.12.0 instead of 0.11.0.

I tried with a dockerized node 8.9 and again run into problems, with both mermaid.cli 0.2.1 and 0.3.1

It could be tracked down to https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322838700 I tried the workaround there of using {args: ['--no-sandbox', '--disable-setuid-sandbox']} and it worked, but this is not an acceptable solution security-wise.

agusmba commented 6 years ago

Maybe @tylerlong can take a look... @angrykoala could you also check https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

just in case there are some dependencies missing at the OS level?

angrykoala commented 6 years ago

@agusmba All dependencies are installed in my system, and it is werid that it is a dependency when the problem is explicitly about an unhandled promise

agusmba commented 6 years ago

The problem appears to be puppeteer failing to properly launch chrome. There seem to be many different reasons for failing to launch chrome, like an antivirus (my case), missing deps, or lack of kernel support.

Does mermaid.cli version 0.2.1 work for you?

angrykoala commented 6 years ago

Trying to install/uninstall (as sudo) mermaid.cli globally fails with the following error:

fs.js:885                                                                                                                                                      
  return binding.mkdir(pathModule._makeLong(path),                                                                                                             
                 ^                                                                                                                                             

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/mermaid.cli/node_modules/puppeteer/.local-chromium'                                       

I'm not sure if this error is related or may help to this issue

agusmba commented 6 years ago

For what it's worth, version 0.3.1 is working fine on my windows 7 box (no antivirus issues either), node v6.11.0

@angrykoala it sure looks like there's a problem with your puppeteer / chromium

agusmba commented 6 years ago

0.3.1 also working on my windows 10 (convinced the antivirus that chrome.exe is safe).

lf-araujo commented 6 years ago

Can confirm this happens in Ubuntu 17.10.

diversemix commented 6 years ago

Manually fettling package.json to include v0.13.0 of puppeteer within the mermaid.cli package seems to have got the mmdc working for me.

diversemix commented 6 years ago

Ok ... As part of my testing I reverted the version of puppeteer back to 0.12 to make sure it still did not work ... but it did work. This is confusing as now everything is working fine and I cannot get things to break again. Leaving this here in case it helps!

tylerlong commented 6 years ago

I cannot reproduce the issue you reported.

If you are having issues, please try the following:

  1. Install mermaid.cli locally instead of globally. And invoke the binary by ./node_modules/.bin/mmdc. Sometime YARN or NPM just failed to install this library globally properly due to some weird permission issues. Installing it locally will fix the issue.
  2. Upgrade your Node.js. Node 6.x is pretty old in my opinion. If there is nothing preventing your from upgrading why not just upgrade?
  3. If you are still experience this issue. Please reopen this issue or create a new issue and list the detailed steps to reproduce the issue(including your OS version, node version and the commands you issued.)
Salzi commented 6 years ago

@tylerlong I have the same issue (can't reopen the issue). Here is what I did:

locate mmdc
/home/jonas/Documents/node_modules/.bin/mmdc
/usr/lib/node_modules/mermaid-filter/node_modules/.bin/mmdc
graph LR
A-->B;

(node:11047) UnhandledPromiseRejectionWarning: Error: spawn EACCES at ChildProcess.spawn (internal/child_process.js:330:11) at Object.exports.spawn (child_process.js:500:9) at Function.launch (/home/jonas/Documents/node_modules/puppeteer/lib/Launcher.js:106:40) at (node:11047) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:11047) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My setup: OS: Manjaro (Linux): Linux 4.4.126-1-MANJARO #1 SMP PREEMPT Sat Mar 31 17:16:02 UTC 2018 nodeJS: 9.9.0-2 mmdc: 0.4.5

Let me know if you need more information.

tylerlong commented 6 years ago

@Salzi

If you install it locally (in your current folder), you don't need to locate it at all.

Just ./node_modules/.bin/mmdc -i ...

The binary you located might not be the one you just installed.

And from the error message, it is a permission issue. You can try sudo.

tylerlong commented 6 years ago

Tested on ubuntu Linux:

tyler@tyler-VirtualBox:~/src$ cd temp
tyler@tyler-VirtualBox:~/src/temp$ ls
flowchart.mmd
tyler@tyler-VirtualBox:~/src/temp$ yarn add mermaid.cli
yarn add v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.5.1" while you're on "1.3.2".
info To upgrade, run the following command:
$ sudo apt-get update && sudo apt-get install yarn
success Saved 49 new dependencies.
├─ agent-base@4.2.0
├─ ansi-styles@3.2.1
├─ async-limiter@1.0.0
├─ balanced-match@1.0.0
├─ brace-expansion@1.1.11
├─ chalk@2.3.2
├─ color-convert@1.9.1
├─ color-name@1.1.3
├─ commander@2.15.1
├─ concat-map@0.0.1
├─ concat-stream@1.6.0
├─ core-util-is@1.0.2
├─ debug@2.6.9
├─ es6-promise@4.2.4
├─ es6-promisify@5.0.0
├─ escape-string-regexp@1.0.5
├─ extract-zip@1.6.6
├─ fd-slicer@1.0.1
├─ fs.realpath@1.0.0
├─ glob@7.1.2
├─ has-flag@3.0.0
├─ https-proxy-agent@2.2.1
├─ inflight@1.0.6
├─ inherits@2.0.3
├─ isarray@1.0.0
├─ mermaid.cli@0.4.6
├─ mime@1.6.0
├─ minimatch@3.0.4
├─ minimist@0.0.8
├─ mkdirp@0.5.0
├─ ms@2.0.0
├─ once@1.4.0
├─ path-is-absolute@1.0.1
├─ pend@1.2.0
├─ process-nextick-args@2.0.0
├─ progress@2.0.0
├─ proxy-from-env@1.0.0
├─ puppeteer@1.3.0
├─ readable-stream@2.3.6
├─ rimraf@2.6.2
├─ safe-buffer@5.1.1
├─ string_decoder@1.1.1
├─ supports-color@5.3.0
├─ typedarray@0.0.6
├─ ultron@1.1.1
├─ util-deprecate@1.0.2
├─ wrappy@1.0.2
├─ ws@3.3.3
└─ yauzl@2.4.1
Done in 43.44s.
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -i flowchart.mmd 
tyler@tyler-VirtualBox:~/src/temp$ ls
flowchart.mmd  flowchart.mmd.svg  node_modules  package.json  yarn.lock
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -i flowchart.mmd -o flowchart.png
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -v

  error: unknown option `-v'

tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -V
0.4.6
tyler@tyler-VirtualBox:~/src/temp$ 

I am not going to test other Linux distributions because there are so many of them. If it doesn't work for your distribution, it's probably not mermaid.cli's issue.