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

marp.exe rendering and watch mode do not work in msys on Windows 10 (i.e. git-bash)

Open embix opened this issue 1 year ago • 3 comments

Version of Marp Tool

@marp-team/marp-cli v3.4.0 (w/ @marp-team/marp-core v3.9.0)

Operating System

Windows

Environment

  • OS version: Windows 10 22H2 Build 19045.4291
  • Node.js version: the one baked into Marp CLI, when using npx it's the rather rusty 17.9.0
  • Shell Environment: msys/bash (git-bash as distributed with git 2.44.0 for Windows)

Bug occurs in marp.exe as well as when using npx @marp-team/marp-cli@latest

How to reproduce

  1. open git-bash
  2. create a minimal prez.md
  3. either npx @marp-team/marp-cli@latest prez.md -o prez.html
    or /path/to/marp prez.md -o prez.html
  4. it seems to freeze

marp --help or marp --version however work as expected. Using WindowsTerminal/Powershell works as expected.

Expected behavior

It should render the html/pdf or go into watchmode as requested and provide the usual [INFO]/[WARN] outputs accordingly.

Actual behavior

the msys terminal freezes

Additional information

Already tried running with MSYS_NO_PATHCONV=1 just in case it's related to msys's Posix path conversion but that didn't help.

embix avatar Apr 12 '24 08:04 embix

Duplicated: marp-team/marp#500

Workarounds: Add --no-stdin option, or run CLI through winpty bridge.

yhatt avatar Apr 12 '24 09:04 yhatt

When attempting to convert files to PDF and other formats using Marp, it was observed that the conversion works fine when executed via the command line. However, when trying to execute the command using Java's ProcessBuilder to build and run the process, Runtime.getRuntime().exec("marp demo.md -o demo.pdf").start() it results in a timeout and conversion failure. Upon investigation, it was found that this method fails to start Marp properly. Adding the command option "--no-stdin" resolves the issue.

taeyeon-0309 avatar Aug 12 '24 08:08 taeyeon-0309

@taeyeon-0309 Yes, several languages will establish stdio pipes when spawning an external process, so the conversion will not start until stdin is explicitly closed.

This is not only for Java but also for other languages such as Node.js. e.g. https://stackoverflow.com/questions/69700292/node-js-exec-to-build-marp-markdowns-doesnt-work (but the solved answer is not using --no-stdin, and proposed using execSync that will implicitly close stdin: https://github.com/nodejs/node/issues/2339)

Node.js API for Marp CLI is disabled stdin by default, but you may need to use --no-stdin if you want to use CLI without API.

yhatt avatar Aug 13 '24 01:08 yhatt