Found the culprit! For some reason, it’s looking for the filter script under /usr/lib instead of /usr/local/lib.
Try:
QUERY_STRING="url=myrepo.git/tree/myfile" CGIT_CONFIG="/usr/local/etc/cgitrc" /usr/local/www/cgit/cgit.cgi >out.html 2>err.log
then look at the log.