I notice that this issue is ancient, however I've just had a similar issue.
I used
function mymodule_xautoload($adapter) {
$adapter->absolute()->composerDir('../vendor/composer');
}and then I got an error when calling drush (for example drush cc)
PHP Fatal error: Cannot declare class OpenAI, because the name is already in use in /home/staging/deploy/vendor/openai-php/client/src/OpenAI.php on line 8
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot declare class OpenAI, because the name is already in use in
/home/staging/deploy/vendor/openai-php/client/src/OpenAI.php, line 8 [0.28 sec, 45.44 MB]Changing all the requires to require_once in src/Discovery ComposerJson.php, ComposerDir.php and ComposerJsonTargetDir.php fixed this for me.