Unfortunately, while the mtxrun command works for a shell user:
$ mtxrun -script base --variables | grep cache
resolvers | lists | env: $SELFAUTOPARENT/texmf-cache
resolvers | lists | var: $SELFAUTOPARENT/texmf-cache
resolvers | lists | exp: /opt/context/tex/texmf-cache
resolvers | lists | res: /opt/context/tex/texmf-cache
the result is the same for www-data:
$ sudo -u www-data bash -c ". /opt/context/tex/setuptex /opt/context/tex; mtxrun --script base --variables | grep cache"
resolvers | caches | fatal error: there is no valid writable cache path defined
I have to think that setuptex isn't able to set up the runtime
environment for www-data, somehow?