[Tex/LaTex] ghostscript: mactex conflicts with homebrew


I am using auctex and previewing equations in emacs does not work for me. It seems that the problem is related to ghostscript. I tried to reinstall ghostscript using brew, but got the following error.

brew reinstall ghostscript
==> Reinstalling ghostscript 
==> Downloading https://homebrew.bintray.com/bottles/ghostscript-9.52.mojave.bottle.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/91f3c9535bda739dd9663190e036d7661f4e27463b96ea05c9b5db5a98ca9abe--ghostscript-9.52.mojave.bottle.tar.gz
==> Pouring ghostscript-9.52.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/dvipdf
Target /usr/local/bin/dvipdf
already exists. You may want to remove it:
  rm '/usr/local/bin/dvipdf'

To force the link and overwrite all conflicting files:
  brew link --overwrite ghostscript

To list all files that would be deleted:
  brew link --overwrite --dry-run ghostscript

Possible conflicting files are:
/usr/local/share/man/man1/eps2eps.1 -> /usr/local/share/man/man1/ps2ps.1
/usr/local/share/man/man1/gsbj.1 -> /usr/local/share/man/man1/gslp.1
/usr/local/share/man/man1/gsdj.1 -> /usr/local/share/man/man1/gslp.1
/usr/local/share/man/man1/gsdj500.1 -> /usr/local/share/man/man1/gslp.1
/usr/local/share/man/man1/gslj.1 -> /usr/local/share/man/man1/gslp.1
/usr/local/share/man/man1/ps2pdf12.1 -> /usr/local/share/man/man1/ps2pdf.1
/usr/local/share/man/man1/ps2pdf13.1 -> /usr/local/share/man/man1/ps2pdf.1
/usr/local/share/man/man1/ps2pdf14.1 -> /usr/local/share/man/man1/ps2pdf.1
==> Summary
🍺  /usr/local/Cellar/ghostscript/9.52: 671 files, 87.4MB
==> `brew cleanup` has not been run in 30 days, running now...
Error: Permission denied @ apply2files - /usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb

I looked online and saw that there is probably a conflict with MacTex (see this GitHub issue). Indeed I have MacTex 2015 installed.

I am not sure how to proceed in solving the problem.

Should I uninstall MacTex and then reinstall it? (It seems it cannot be done thoroughly)

Should I force the homebrew links as it suggests? It seems like other stuff will be broken by it.

I am a simple TeX user, so I don't really understand all the dependencies. My goal it to be able to preview the equations when writing latex in emacs. (BTW, I am able to view the equations when I write in orgmode on emacs).

Best Answer

I use brew doctor and get a list of all broken symlinks.
In this list you will find /usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb and some other like this.
Then use sudo rm '/usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb' to remove it.
Maybe there are more than one in the same directory so you can use sudo rm -r '/usr/local/share/ghostscript/9.10/Resource/Font'.
Maybe this helps.

Related Question