timofurrer / pandoc-mermaid-filter

Pandoc filter for mermaid code blocks
MIT License
75 stars 21 forks source link

linux, mermaid not found #9

Closed mmngreco closed 4 years ago

mmngreco commented 4 years ago

Hi guys!

When I ran pandoc I got a FileNotFoundError:

$ pandoc file.md -o file.md.pdf --filter pandoc-mermaid
Traceback (most recent call last):
  File "/home/mgreco/.local/bin/pandoc-mermaid", line 11, in <module>
    sys.exit(main())
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandoc_mermaid_filter.py", line 38, in main
    toJSONFilter(mermaid)
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandocfilters.py", line 132, in toJSONFilter
    toJSONFilters([action])
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandocfilters.py", line 166, in toJSONFilters
    sys.stdout.write(applyJSONFilters(actions, source, format))
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandocfilters.py", line 197, in applyJSONFilters
    altered = walk(altered, action, format, meta)
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandocfilters.py", line 124, in walk
    x[k] = walk(x[k], action, format, meta)
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandocfilters.py", line 111, in walk
    item['c'] if 'c' in item else None, format, meta)
  File "/home/mgreco/.local/lib/python3.6/site-packages/pandoc_mermaid_filter.py", line 31, in mermaid
    subprocess.check_call([MERMAID_BIN, "-i", src, "-o", dest])
  File "/home/mgreco/miniconda3/envs/tesser/lib/python3.6/subprocess.py", line 306, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/home/mgreco/miniconda3/envs/tesser/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/home/mgreco/miniconda3/envs/tesser/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/home/mgreco/miniconda3/envs/tesser/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '~/node_modules/.bin/mmdc': '~/node_modules/.bin/mmdc'
Error running filter pandoc-mermaid:
Filter returned error status 1
mmngreco commented 4 years ago

The solution was converto in absolute path the MERMAID_BIN key.

In my case:

from: MERMAID_BIN='~/node_modules/.bin/mmdc'

to: MERMAID_BIN='/home/mgreco/node_modules/.bin/mmdc'

timofurrer commented 4 years ago

@mmngreco I've just pushed a fix for this. It's now expanding the user in the MERMAID_BIN variable.

mmngreco commented 4 years ago

That's good news! Thanks!