简体   繁体   中英

Sublime text 2, make cannot find pandoc, OSX

Background

My current workflow to create/process markdown documents uses Sublime Text 2 with a Makefile build system, which calls pandoc to process them into PDF documents.

I've recently purchased a new mac, running OSX 10.8.5, and I've been running into some problems.

What's working:

I've installed Sublime Text 2, make (from xcode command line tools) and Pandoc (using the package on the website, as the cabal version wouldn't build for me).

What's not working:

When I try and build documents, it fails with the following error message from make:

pandoc -V geometry:margin=1in -S -o project_specification.pdf project_specification.markdown
make: pandoc: No such file or directory
[Finished in 0.0s with exit code 2]make: *** [project_specification.pdf] Error 1

The makefile however build absolutely fine if I run it using make at the terminal.

I think this is a problem with my path, however I'm really not sure how to set it. My understanding is that OSX has multiple paths for different applications (odd to me, as a Linux user until now), and I'm not sure how to set it for sublime to get it to work.

More background:

The makefile:

CPP_FILES = $(wildcard *.markdown)
OBJ_FILES = $(patsubst %.markdown,%.pdf,$(CPP_FILES))

%.pdf: %.markdown
    pandoc -V geometry:margin=1in -S -o $@ $(patsubst %.pdf,%.markdown,$@)

all: $(OBJ_FILES)

clean:
    rm -f *.pdf

And finally:

I've found similar questions out there, but none with comprehensive answers, so I'm turning to stack overflow once again.

Thanks in advance for any help!

How about hack the path to wherever your pandoc is? Sublime Text 2 defaults to: /usr/bin:/bin:/usr/sbin:/sbin . This example is for a Tex Live installation using /usr/texbin , but you get the idea. There is one package that comes to mind that is more difficult to hack (eg, Shell Turtlestein ), but this works in general for most situations. I leave this running all the time when I load Sublime Text 2. If you need the turtle hack, just let me know. There are ways to adjust the path on a per package build script basis ( eg, https://github.com/SublimeText/LaTeXTools/blob/master/LaTeX.sublime-build ), however, the following simplistic plugin usually works:

import os

LOCAL = '/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin:/usr/local/bin'
HOME = '/Users/HOME'  ### !!! REPLACE WITH YOUR HOME PATH !!! ###
RVM = HOME + '/.rvm/bin:'

# Sublime's default path is
# /usr/bin:/bin:/usr/sbin:/sbin
os.environ['PATH'] += ':'
os.environ['PATH'] += LOCAL
os.environ['PATH'] += RVM

print 'PATH = ' + os.environ['PATH']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM