[Tex/LaTex] MacTex: Cannot find input file

mactex

I have a minimal LaTeX file called untitled.tex.

btrost@rt4382m-ggb: ~/Desktop>cat untitled.tex 
\documentclass{article}

\begin{document}

Hi

\end{document}

When I run pdflatex on the file, which obviously exists, it says it can't find the file:

btrost@rt4382m-ggb: ~/Desktop>pdflatex untitled.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded     format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `untitled.tex'.
<*> untitled.tex

(Press Enter to retry, or Control-D to exit)
Please type another input file name: 

I experienced this problem on another Mac and reinstalling MacTex fixed the problem, but on this Mac it did not. I am running Max OS X 10.12.1 (16B2555). This happens on all .tex files, not just the minimal example above. In addition to pdflatex, the same thing happens when I run latex. Any ideas? Thanks in advance for any help!

(Edit)

btrost@rt4382m-ggb: ~/Desktop>ls -alF ~/Desktop/
total 5724648
drwx------+  6 btrost  staff   204B  7 Nov 12:13 ./
drwxr-xr-x+ 69 btrost  staff   2.3K  7 Nov 12:09 ../
-rw-r--r--@  1 btrost  staff   8.0K  7 Nov 12:13 .DS_Store
-rw-r--r--   1 btrost  staff     0B 30 Jun 17:03 .localized
-rw-r--r--@  1 btrost  staff   2.7G  7 Nov 10:33 mactex-20161009.pkg
-rw-r--r--@  1 btrost  staff    62B  7 Nov 10:53 untitled.tex

Permissions seem fine to me. If I double-click on the file, it opens in TeXShop. If I try to typeset it in TeXShop, it does work (!). In TeXShop, when I go to preferences and then the "engine" tab, (pdf)tex is set to /Library/TeX/texbin. However, when I write /Library/TeX/texbin/pdflatex untitled.tex at the command line (cwd = Desktop), I get the can't find file error.

samcarter: If I run pdflatex /Users/btrost/Desktop/untitled.tex, I get the following. It appears that it does find the file this time (but for some reason cannot find article.cls). Perhaps this is diagnostic? Thank you all once again for the help!! I really appreciate it.

btrost@rt4382m-ggb: ~/Desktop>pdflatex /Users/btrost/Desktop/untitled.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/Users/btrost/Desktop/untitled.tex
LaTeX2e <2016/03/31>
 Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.

! LaTeX Error: File `article.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name: 

Also, I updated to sierra. I think this problem started when I updated. Here are the outputs of which latex and echo $PATH:

btrost@rt4382m-ggb: ~/Desktop>echo $PATH
/Users/btrost/google-cloud-sdk/bin:/Users/btrost/scripts:/Users/btrost/scripts/context_specific:Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/texlive/2016/bin/universal-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin
btrost@rt4382m-ggb: ~/Desktop>which pdflatex
/usr/local/texlive/2016/bin/universal-darwin/pdflatex

Looks like pdflatex does live in two different places: /usr/local/texlive/2016/bin/universal-darwin/ and /Library/TeX/texbin. Not sure if this is "normal" or not. They both have the same problem, though.

Here's where /Library/TeX/texbin points:

btrost@rt4382m-ggb: /Applications/IGV_2.3.80.app/Contents/Java>ls -l /Library/TeX/texbin
lrwxr-xr-x  1 root  wheel    63B  7 Nov 10:43 /Library/TeX/texbin@ -> /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin

@ means extended attributes. I don't think it has anything to do with permissions (see https://discussions.apple.com/thread/1202723?start=0&)

Best Answer

After dealing with the problem off line it was determined that TEXINPUTS was being set and didn't contain the leading .: so pdflatex didn't look in the working directory.

The removal of that extra path let's the 64bit TeX binaries be used which are found at /Library/TeX/texbin (a doubly indirect symbolic link to the 64bit binaries under Sierra---used to easily change the active distribution using TeX Live Utility). Not necessary but useful.

Related Question