I got this error when trying to running phpcs from another folder. Try to stick to the root when your run the code.
Do
vendor/bin/phpcs -p web/modules/custom ...
Instead of
../../../vendor/bin/phpcs -p custom ...
Buy me a drink 🍺