zacharyvoase / markdoc

A lightweight Markdown-based wiki system. Current status: abandoned.
http://markdoc.org/
The Unlicense
347 stars 74 forks source link

Confusing error message if `rsync` is not installed #35

Open LiaungYip opened 9 years ago

LiaungYip commented 9 years ago

On Windows, running Markdoc without rsync installed causes the following confusing error message to be displayed:

PS C:\Users\lws\Documents\GitHub\morrowind-dnd3.5> markdoc build
Traceback (most recent call last):
  File "C:\Python27\Scripts\markdoc-script.py", line 9, in <module>
    load_entry_point('Markdoc==0.6.6', 'console_scripts', 'markdoc')()
  File "C:\Python27\lib\site-packages\markdoc\cli\main.py", line 38, in main
    return command(config, args)
  File "C:\Python27\lib\site-packages\markdoc\cli\commands.py", line 29, in wrapper
    return function(config, args)
  File "C:\Python27\lib\site-packages\markdoc\cli\commands.py", line 270, in build
    sync_html(config, args)
  File "C:\Python27\lib\site-packages\markdoc\cli\commands.py", line 29, in wrapper
    return function(config, args)
  File "C:\Python27\lib\site-packages\markdoc\cli\commands.py", line 238, in sync_html
    subprocess.check_call(command)
  File "C:\Python27\lib\subprocess.py", line 535, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

If we run with the --verbose option we can see this is just after the Markdoc attempts to call rsync which is not installed.

markdoc.sync-html: DEBUG: rsync -vaxq --cvs-exclude --delete --ignore-errors --include=.htaccess --exclude=.* --exclude=_* .tmp/ default-static/ static/ .html/

Markdoc should trap this exception and produce a more useful error message, such as OSError: rsync not installed or could not be found.


Actually it's even worse than this; I do have rsync installed (via cwRsync) but Python can't find it. This is a Windows specific bug. The problem is at commands.py:238 where subprocess.check_call() is called with the default argument of shell=False. To quote from Walter Mundt's StackOverflow answer - "Also, on Windows with shell=False, it pays no attention to PATH at all, and will only look in relative to the current working directory". So even though rsync is on my path, Python on Windows can't find it.

snoozbuster commented 9 years ago

Aha! I was wondering why this was happening. Enlightening.

snoozbuster commented 9 years ago

I know this is pretty old, but I forked this project and rewrote the sync stuff in pure Python; as it turns out there's a bug in make_relative at render.py:35 that causes relative resolution to fail on Windows for source files due to differing path separators. So even with rsync, building wouldn't have worked properly.