Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering not functional on Mac #39

Closed
asbisen opened this issue Aug 25, 2013 · 17 comments
Closed

Rendering not functional on Mac #39

asbisen opened this issue Aug 25, 2013 · 17 comments

Comments

@asbisen
Copy link

asbisen commented Aug 25, 2013

I am unable to render rst files on Mac. I have rst2pdf and pandoc both installed and functional using MacPorts.

When I execute rendering option (rst2pdf) I get two pop-ups the first says

  1. The file "tmp4aXEnO.pdf" could not be opened because it is empty
  2. Fail to generate output. [Errno 2] No such file or directory

Am I missing something?

@mgaitan
Copy link
Owner

mgaitan commented Aug 26, 2013

Hi @asbisen,

Probably you aren't missing anything but it's just a bug: I have no mac to test it.

Do you know a bit of python? could you help me to debug it?

@asbisen
Copy link
Author

asbisen commented Aug 26, 2013

@mgaitan sure would be happy to assist. I do know a bit of Python but am new to Sublime. Let me know how you'd want to proceed.

@mgaitan
Copy link
Owner

mgaitan commented Aug 26, 2013

Thanks.

The render feature is done calling external tools via subprocess in
render.py model. It's very easy. As every TextCommand plugin the method
run is the launcher. It show the quickwindow and bind the user choice
with the method convert, where two things happen:

  1. copy the content of the buffer in a temporal .rst file, and create an
    empty "target file" (depending the target format it would be pdf, html,
    etc) .
  2. call the convert tool via run_tool method.
  3. open the target file via open_result method.

I guess the problem is in the subprocess call done in run_tool. You can
done do a trivial step-by-step debugging inserting a line like in a point.

  print <object>; return

you can see the output in the python console built-in

try to figure out which is the exact command list subprocess is trying to
call, check the content of the temporary .rst, if the target file exists,
and try to call a similar command directly from the console.

btw, are you using sublime 2 or 3?

thanks in advance

https://github.com/dbousamra/sublime-rst-completion/blob/master/render.py

On Mon, Aug 26, 2013 at 12:00 PM, asbisen [email protected] wrote:

@mgaitan https://github.com/mgaitan sure would be happy to assist. I do
know a bit of Python but am new to Sublime. Let me know how you'd want to
proceed.


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-23268473
.

mgaitan.github.io
textosyprextextos.com.ar

@asbisen
Copy link
Author

asbisen commented Aug 26, 2013

Okay so I did some tinkering and here are the findings:

  1. The problem with rst2pdf is that when executed from within sublime it does not finds the path of the binary. Although the path is defined in the system and is accessible through terminal. The subprocess.call is not looking at the system path.
    • If I manually add the following in line 69 tool="/opt/local/bin/" + tool then rst2pdf plugin starts working
  2. Pandoc modules are a different story. On macports although pandoc is installed when I execute the pandoc conversion from command line it fails as first it was unable to find pdflatex and upon installing all the tex packages it fails to find some template named "lmodern.sty"

$ /opt/local/bin/pandoc /var/folders/x7/d09lcfrs63ncsqmy77hxxddc0000gn/T/tmpr5cWyV.rst -o /var/folders/x7/d09lcfrs63ncsqmy77hxxddc0000gn/T/tmpu0bLsa.pdf
pandoc: Error producing PDF from TeX source.
! LaTeX Error: File `lmodern.sty' not found.

Type X to quit or to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.4 \usepackage

@asbisen
Copy link
Author

asbisen commented Aug 26, 2013

And the pandoc issue was resolved by installing the following packages

$ sudo port install texlive-fonts-extra texlive-fonts-recommended texlive-fontutils so now my pandoc and rst2pdf both modules are working if I add tool="/opt/local/bin/" + tool on line number 69 in render.py.

Question I have is that how do I make these changes with Sublime3 as it zips up the packages. Would it be as simple as renaming the package with a zip extension; uncompressing the zip archive; make the change and then zip it up again?

@mgaitan
Copy link
Owner

mgaitan commented Aug 31, 2013

Ok @asbisen, good to know you can move forward with this. Do you think we should keep that tool path configurable? or just set the absolute path /opt/local ... in osx?

about st3, really I'm not sure, but I guess it also works if it uncompressed in the packages folder.
thanks for your help

@asbisen
Copy link
Author

asbisen commented Aug 31, 2013

@mgaitan I don't think that would a good approach. If you make it an absolute path /opt/local/bin then it would only solve the issue for a small number of users. As there would be multiple different systems that a Mac user could use for installing these packages (MarcPorts, HomeBrew, Fink and maybe more).

Additionally even with macports there could be multiple different variation of the executable rst2html-2.7.py (the 2.7 could be replaced by 3.0, 3.2 etc).

_Either you cover for all of the scenarios and perform some path lookups or just have a section in Readme where you ask the users to create a symbolic link of rst2html.py to their version on the binary and place it in a location which is in the path (suggest /usr/bin for example)._

@asbisen asbisen closed this as completed Aug 31, 2013
@asbisen asbisen reopened this Aug 31, 2013
@mgaitan
Copy link
Owner

mgaitan commented Aug 31, 2013

I was thinking in a .sublime-settings file where the user could define manually the path the programs are installed.

For example https://github.com/jclement/SublimePandoc/blob/master/Pandoc.sublime-settings

@sloria
Copy link

sloria commented Sep 23, 2013

I am still having this problem on ST3 on Mac OSX 10.7 with docutils 0.11. I am trying to render RST to HTML using the rst2html command. I have verified that rst2html.py and a symlink rst2html are in my path.

It is working on ST2, but not on ST3. Any ideas on this?

@jimklo
Copy link
Contributor

jimklo commented Oct 1, 2013

I got this working by hacking the following custom plugin in: https://gist.github.com/6784840

It seems there should be an easier way to modify the ST's python environment - modifying the Python.submlime-build file did nothing for me.

@sloria
Copy link

sloria commented Dec 8, 2013

@jimklo How do you install your "hack"? Have you tried it with ST3?

@jimklo
Copy link
Contributor

jimklo commented Dec 8, 2013

@sloria. Create a new plugin "Tools" > "New Plugin..." And that will create a boilerplate plugin. Replace the contents with the Gist, then save in a new directory inside the User directory. Directory should be called Pathmaster. Restart ST and /usr/local/bin and /usr/local/sbin should be on the Python Path.

Not tested on ST3 but it's such a trivial plugin, it should just work.

@sloria
Copy link

sloria commented Dec 8, 2013

Thanks for the prompt reply. The plugin does successfully change the path, but still doesn't solve the rst2html.py problem. =\

@QuentinRoy
Copy link

I have the same issue here... I tried to install @jimklo's hack.. But nothing changed. I'm really new to sublime though.. Did you find a way to solve this issue @sloria ?

@mgaitan
Copy link
Owner

mgaitan commented Dec 13, 2013

Please, if somebody find a solution, could send a PR ? I have no access to a mac

@jimklo
Copy link
Contributor

jimklo commented Dec 13, 2013

@mgaitan The problem is pretty much about altering ST's environment to include the location of rst2html. If you take a look at the Gist I posted, all it is a new plugin that puts /usr/local/bin and /usr/local/sbin on the environment path. A similar solution would be needed for windows - say if had rst2html installed in C:\Programs\Python\bin, you would need to alter the os.environment to put C:\Programs\Python\bin onto ST's environment path.

If I get some time.. I might be able to figure out this project's architecture and insert the initialization sequence... the optimal method would be to add this via the config file as opposed through the hard-coded solution I did.

@mgaitan
Copy link
Owner

mgaitan commented Dec 16, 2013

With the PR @jimklo sent should be possible to config the custom path were the executables are. I'll open a new ticket to document this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants