texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.77k stars 343 forks source link

Texstudio fails to find gs on M1 Macs #2293

Closed BrushXue closed 2 years ago

BrushXue commented 2 years ago

Installed mactex-no-gui (and gs as dependency). Texstudio failed to find gs and can't convert .eps to .pdf

Environment

Expected behavior

Installed same packages on my x86 Mac with no issue.

Actual behavior

epstopdf ($Id: epstopdf.pl 48681 2018-09-16 23:03:58Z karl $) 2.28 !!! Error: Cannot open Ghostscript for piped input: gs -q -dSAFER -dNOPAUSE -dBATCH -dCompatibilityLevel=1.5 -sDEVICE=pdfwrite -sOutputFile=fig/cru-eps-converted-to.pdf -dPDFSETTINGS#/prepress -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoRotatePages#/None - -c quit

Screen Shot 2022-04-29 at 9 38 00 AM I guess the problem is the different path on M1

$ which gs
/opt/homebrew/bin/gs

How to reproduce

brew install --cask mactex-no-gui texstudio
sunderme commented 2 years ago

that is why you can can manually set the path.

sunderme commented 2 years ago

it is unclear in what context epstopdf is called. But that specifically is a PATH issue (which has even less to do with txs)

muzimuzhi commented 2 years ago

@BrushXue Does your problem reproduce if you manually run pdflatex or xelatex in Terminal.app?

sunderme commented 2 years ago

no feedback

BrushXue commented 2 years ago

@BrushXue Does your problem reproduce if you manually run pdflatex or xelatex in Terminal.app?

No. In terminal or VScode everything's fine. Only texstudio can't find gs.

BrushXue commented 2 years ago

@sunderme Let me clarify it again: x86 Mac + MacTeX.pkg(with gs) + texstudio = no problem. x86 Mac + brew install mactex-no-gui + texstudio = no problem M1 Mac + MacTeX.pkg(with gs) + texstudio = no problem. M1 Mac + brew install mactex-no-gui+ terminal/vscode = no problem M1 Mac + brew install mactex-no-gui+ texstudio = can't open gs

On x86 Mac

$ which gs
/usr/local/bin/gs

On M1 Mac

$ which gs
/opt/homebrew/bin/gs

I think the problem is very clear as gs is installed separately in another directory (and that directory changed in ARM Macs according to https://docs.brew.sh/Installation)

sunderme commented 2 years ago

looks like a PATH error. see #1740

BrushXue commented 2 years ago

Let me try if adding /opt/homebrew/bin/ works https://github.com/texstudio-org/texstudio/blob/2589d22696f44977a4ecd475824749719d31723c/src/buildmanager.cpp#L910

BrushXue commented 2 years ago

I added the path and compiled again, the GUI can find gs automatically. Screen Shot 2022-05-07 at 11 39 41 PM However I still get the same error

epstopdf ($Id: epstopdf.pl 48681 2018-09-16 23:03:58Z karl $) 2.28 !!! Error: Cannot open Ghostscript for piped input: gs -q -dSAFER -dNOPAUSE -dBATCH -dCompatibilityLevel=1.5 -sDEVICE=pdfwrite -sOutputFile=fig/cru-eps-converted-to.pdf -dPDFSETTINGS#/prepress -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoRotatePages#/None - -c quit
BrushXue commented 2 years ago

With the additional $PATH, the document can be compiled. /opt/homebrew/bin/ is a kind of "standard" $PATH in ARM Macs. There should be a seamless solution for this. Screen Shot 2022-05-08 at 12 01 50 AM

sunderme commented 2 years ago

The problem is that the PATH is not set correctly in .profile or whatever mac uses as source for the variable when a GUI app is started. (it is not .bashrc) If you start txs from command line, PATH is correct and everything works. txs uses currently a method which is recommended by apple to gather all the PATH information. If you find a better solution, please provide a PR/patch.

lueck1803 commented 1 year ago

I experience a similar problem.

Texstudio dont read ether the .bashrc, .bashprofile, .zshrc or .zprofile.

Its only aware of the paths: usr/bin:/bin:/usr/sbin:/sbin Except the additional paths i add in the .ini or through preferences -> build.

This information i got by using terminal commands like "echo $PATH" under preferences ->build ->user commands. Even the additional search paths i added are not available through this texstudio invoked terminal.

I wanted edit my own type of latex sub document compile. it with a python program i start through this user command and show the generated pdf file in the texstudio internal pdf viewer. This works fine on linux, but not on my M1 mac, because of this paths issues. This Texstudio invoked terminal isn't able to find my environment variables i defined in .zprofile and .zshrc. But only the terminal. If i use my environment variable to define standard bibfile paths it works fine. (ex. \bibliography{talk.bib,$ZETTELKASTEN_STD_BIBTEX)

Because of the path issue that the path is constrained to usr/bin:/bin:/usr/sbin:/sbin, it finds an older python version. which python3 gives: /usr/bin/python3 And python3 --version: 3.9.6 My version i installed by homebrew is 3.10.8.

I tried to find out why texstudio don't loads any of my rc or profile or login files, but i got no conclusion

Thanks for any help.