Hannah-Sten / TeXiFy-IDEA

LaTeX support for the IntelliJ platform by JetBrains.
https://hannah-sten.github.io/TeXiFy-IDEA
MIT License
892 stars 89 forks source link

How to manage the compiler #25

Closed jbournonville closed 7 years ago

jbournonville commented 7 years ago

Hello i am on mac version of intellij. I have installed MacTex. I get an error message when i am trying to compile

Error running rapport: Cannot run program "pdflatex" (in directory "/Users/julien/Desktop/TWCS/00 - PROJET/REPORT/src"): error=2, No such file or directory

How can i configure the path for the compiler ?

regards

JBo

HannahSchellekens commented 7 years ago

Currently only pdflatex is supported (see feature overview). We are of course planning to support multiple compilers in the form of Project SDKs which is something @stenwessel is working on if I recall correctly.

Temporary workaround: Write a compilation script and add that as a 'Before Launch' action in your run configuration. That way you should be able to compile everything. It does however complicate things a bit more.

image

ashkan-leo commented 7 years ago

I'm also having an issue using "pdflatex". I have it installed on my macOS; however when I try to compile I get the same error. I can use pdflatex from the terminal.

jbournonville commented 7 years ago

It should be great to be able to locate the pdflatex script in as an input for the config. @RubenSchellekens can be a bit more explicit on adding an external tool before lunch ?

stenwessel commented 7 years ago

@jbournonville Right now it we do not support custom paths for the pdlatex executable, but we will add that soon. Documentation on external tools can be found here.

Also, make sure pdflatex is in your path by typing pdflatex in the terminal and checking if it can be found. If it is in your path and you still have the issue, please let me know.

jbournonville commented 7 years ago

@RubenSchellekens I tested the pdflatex command in the terminal and it found it : julien -> pdflatex This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex) restricted \write18 enabled. So i add it to the external tool but nothing happen when i run the config : /usr/local/texlive/2016/bin/x86_64-darwin/pdflatex This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex) restricted \write18 enabled. **

capture d ecran 2017-07-10 a 12 50 15

Did i do something wrong ?

Regards

jbournonville commented 7 years ago

With main.tex in parameters field, it generate the pdf.

capture d ecran 2017-07-10 a 13 16 08

Do you have a release date for the custom paths feature ? Because for now i can't take advantage of the directory managment (pdf in /out ...).

stenwessel commented 7 years ago

Since I am not quite sure what is causing your issue we will include custom paths in the upcoming b0.3 release. I think we will have this release ready in a couple of days.

stenwessel commented 7 years ago

@jbournonville I have submitted a pull request for a fix. I have built a preliminary version of the plugin available for download here (TeXiFy IDEA.zip). I would love to hear if this resolves your issue (I cannot test myself since I do not have a mac machine available). Please ignore the NullPointerExceptions, we are working on those :)

You can install this version by extracting the JAR from the ZIP, open IntelliJ Settings > Plugins and click Install plugin from disk to select the JAR file.

The fix will also be included in the b0.3 release alongside many other features.

miller-w commented 7 years ago

The problem seems to be the not fully loaded PATH env variable.

workaround: call intellij from command line e.g.:

open -a "IntelliJ IDEA CE"

http://depressiverobot.com/2016/02/05/intellij-path.html

stenwessel commented 7 years ago

@miller-w Thanks for the analysis, at least we know the root of the problem.

For now, the workaround by @miller-w can be used, or as an alternative you can select the custom compiler path in the run configuration settings (see #66). The latter option will be available in the b0.3 release by the end of the week.

Looking forward, we will try to eliminate the need to provide a custom path by creating LaTeX SDKs such that the compiler path can be automatically discovered. (similar to how you select a Java SDK/JDK for Java projects). This is planned for the b0.4 release.

jbournonville commented 7 years ago

@stenwessel it seems that with the custom path, pdflatex is well launch, but the process does result in an error and could not generate the PDF.

./main.tex:51: Emergency stop.
\@include ...\immediate \openout \@partaux #1.aux 
                                                  \immediate \write \@partau...
l.51     \include{includes/resume/main}

./main.tex:51:  ==> Fatal error occurred, no output PDF file produced!
Transcript written on /Users/julien/Desktop/test/out/main.log.

When i do the pdflatex command in the terminal there is no error and PDF is generated correctly.

miller-w commented 7 years ago

@jbournonville create a folder called out in your project root

see also: https://github.com/Ruben-Sten/TeXiFy-IDEA/issues/70

jbournonville commented 7 years ago

@miller-w I already have the out directory, since i create the project using Texify plugin template.

Does the fix working for you ?

jbournonville commented 7 years ago

@miller-w @stenwessel I found a solution to my problem. It seems that \include{} does not work well, i replace them by \input{} and it works fine. @stenwessel can you tell me what we should found in the auxil directory ?

stenwessel commented 7 years ago

@jbournonville The auxil directory is there to contain all the auxiliary files that latex produces when compiling (so, *.aux, *.log, *.bbl, etc.). Normally, they would just be placed in the same directory as the *.tex source file, but you would get all of these files you will never actually open to get in your way in the project view.

In MiKTeX on Windows, there is an option to separate the aux files to the auxil directory (an option that can be enabled in the run configuration). On Mac (and Linux) there is no such option however, so the auxil folder will unfortunately have no use. See also https://tex.stackexchange.com/questions/7265/need-aux-file-in-separate-folder

Since we have no solution for mac and on Windows the auxil separation also brings some problems (see #26), I think we need to look at a different solution. Maybe hiding aux files from the project view is an idea (paging @RubenSchellekens)?

Also, is using \include{} only an issue when compiling from IntelliJ or also when you compile with pdflatex -output-directory=/path/to/out main.tex from the terminal?

jbournonville commented 7 years ago

@stenwessel There is the same issue with \include{} using the terminal. In fact it just appear when we specify the -output-directory. If we just run pdflatex main.tex, \include{} don't cause any issue, but do not include the files in the pdf. So only \input{}works.

jbournonville commented 7 years ago

@stenwessel Do you know if the mac version of MiKTeX can resolve the ouput directory issue ? MiKTeX for Mac

stenwessel commented 7 years ago

@jbournonville Your issue is described here: https://tex.stackexchange.com/questions/64313/pdflatex-xelatex-output-directory-and-subdirectories-when-using-include

In short: using \include{foo} leads to a file foo.aux being created in the output directory. When using \include{path/to/foo}, it wants to create path/to/foo.aux in the output directory, but these subdirectories must be created manually.

I know that MiKTeX on Windows does create these directories automatically (I have no problem compiling similar includes whatsoever). MiKTeX on mac is still experimental but you could give it a try.

Thanks for reporting this though, I will make a separate issue for this.

miller-w commented 7 years ago

@jbournonville

@miller-w I already have the out directory, since i create the project using Texify plugin template. Does the fix working for you ?

yes it works. I use IntelliJ CE and MacTeX. The only issue I had beside the PATH env var was the also mentioned not existing out folder.

HannahSchellekens commented 7 years ago

Wow. Good job @stenwessel. I'm currently not able to work on the project sadly so I'm glad you picked it up.

Shawn-Guo-CN commented 5 years ago

Thanks a lot for this awesome plugin! However, how can I change the compiler to XeLatex?

PHPirates commented 5 years ago

@Air-Fighter Ah yeah that is the one compiler we are still missing. You can create a new issue for that if you want. You can also try to add it yourself (looking at previous pull requests which added a new compiler would be helpful), or otherwise someone else will do it in the near future.

If you need a real quick hack you could try putting xelatex in the executable path in the run configuration but I don't know xelatex so I have no idea if it would work (probably not, depends on available compiler options).

Shawn-Guo-CN commented 5 years ago

@PHPirates Thanks a lot for this quick responce. Actually, I put xelatex in the executable pdflatex directory. Unfortunately, this doesn't work. I'll check how to add a new compiler.

Thanks very much! As I'm a big fan of IDEA, your plugin is reallly awesome.

PHPirates commented 5 years ago

@Air-Fighter Yes, would be great if you could help! You could check #808, older PRs were on an older file structure.

Shawn-Guo-CN commented 5 years ago

@PHPirates This may disappoint you. I tried to fix it up but all attempts failed. I'm really unfamiliar with the architecture of PyCharm as well as Latex compilers.

PHPirates commented 5 years ago

@Air-Fighter No worries, it was worth trying I'm sure :) If you create a new issue for it then you will be notified when we have solved it.

Edit: solved in #832

alexgunsberg commented 1 year ago

I'm suddenly getting this error with DataSpell.

Cannot run program "pdflatex" (in directory "/Users/xxx/latex_scr"): error=2, No such file or directory

I have Texify idea 0.9.1 and Dataspell2023.2.3

Can someone help me with this? I tried the commands in the troubleshoot section but I wasn't able to solve the issue.

PHPirates commented 1 year ago

@alexgunsberg It is very unlikely that you are running into this bug from six years ago, so please create a new issue/discussion

It would be helpful if you could add there how you installed LaTeX, if it worked before, and how you added pdflatex to PATH.

alexgunsberg commented 1 year ago

I managed to trace down the issue. If I launch DataSpell from the Anaconda Navigator, the Latex Distribution selection will be empty and can't be selected either. Launching DataSpell as usual, has MiKTeX set, and it compiles on my Mac. Moreover, the "Select custom compiler executable path (required on Mac OS X)" needs to be empty on my Mac OS X Sonoma.

PHPirates commented 1 year ago

Interesting, not sure why you would start DataSpell from Anaconda Navigator but I guess Anaconda messes up its path when you start it. Might be an issue with Anaconda. Thanks for the message in any case, yeah I should probably remove the required on Mac part as I don't think that's true anymore

alexgunsberg commented 1 year ago

There is no real reason to launch DataSpell from Anaconda Navigator. The DataSpell icon happens to be the first one there, and if you are managing your environment over there, you feel tempted to click on it. Now that I know the issue, it's easily avoidable, but it took me a whole day to figure it out.

PHPirates commented 1 year ago

That makes sense. Maybe I'll check with them what is going on, thanks.