PROBLEM:
I was having the same problem…
'cat' utility not found in 'PATH'
…when trying to build Curl on WSL2.

CAUSE:
For me it was caused by my value of TMPDIR environment variable. In order to solve some other unrelated issue (in fact related to to BeyondCompare and git mergetool), I had set TMPDIR to point to a folder somewhere on my C Drive - specifically /mnt/c/Users/<username>/AppData/Local/Temp.
An undesired side effect of this is that calling cat with a temporary file fails (i.e. it is not that cat cannot be found, it is that cat cannot find the temporary file).

In the case of Curl: Curl’s “configure” contains the following code…

xc_space=' '
xc_tab='	' 

#
# Verify that 'cat' utility is found within 'PATH', otherwise abort.
#

xc_tst_str='unknown'
xc_tst_str=`cat <<_EOT 2>/dev/null \
  | wc -l 2>/dev/null | tr -d "$xc_space$xc_tab" 2>/dev/null
unknown
unknown
unknown
_EOT`
case "x$xc_tst_str" in # ((
  x3)
    :
    ;;
  *)
    echo "$xc_msg_err 'cat' utility not found in 'PATH'. $xc_msg_abrt" >&2
    exit 1
    ;;
esac

In essence, WSL2 fails to run the following…

cat <<SOME_END_MARKER
Some text
Some more text
Last line of text
SOME_END_MARKER

$ cat <<SOME_END_MARKER

Some text
Some more text
Last line of text
SOME_END_MARKER
cat: -: No such file or directory <==== cat cannot find a a file called “-”
$

i.e. The intention was to check for the presence of cat, but instead it failed because the test was using a temporary file. Cat is fine.

SOLUTION
I fixed it by not overriding the default TMPDIR variable in my ~/.bashrc

I hope this helps someone.

1 Like