@@ -324,7 +324,9 @@ public function createComposer(IOInterface $io, $localConfig = null, $disablePlu
324
324
325
325
// Load config and override with local config/auth config
326
326
$ config = static ::createConfig ($ io , $ cwd );
327
+ $ isGlobal = $ localConfigSource !== Config::SOURCE_UNKNOWN && realpath ($ config ->get ('home ' )) === realpath (dirname ($ localConfigSource ));
327
328
$ config ->merge ($ localConfig , $ localConfigSource );
329
+
328
330
if (isset ($ composerFile )) {
329
331
$ io ->writeError ('Loading config file ' . $ composerFile .' ( ' .realpath ($ composerFile ).') ' , true , IOInterface::DEBUG );
330
332
$ config ->setConfigSource (new JsonConfigSource (new JsonFile (realpath ($ composerFile ), null , $ io )));
@@ -346,6 +348,9 @@ public function createComposer(IOInterface $io, $localConfig = null, $disablePlu
346
348
// initialize composer
347
349
$ composer = $ fullLoad ? new Composer () : new PartialComposer ();
348
350
$ composer ->setConfig ($ config );
351
+ if ($ isGlobal ) {
352
+ $ composer ->setGlobal ();
353
+ }
349
354
350
355
if ($ fullLoad ) {
351
356
// load auth configs into the IO instance
@@ -429,14 +434,14 @@ public function createComposer(IOInterface $io, $localConfig = null, $disablePlu
429
434
430
435
if ($ composer instanceof Composer) {
431
436
$ globalComposer = null ;
432
- if (realpath ( $ config -> get ( ' home ' )) !== $ cwd ) {
437
+ if (! $ composer -> isGlobal () ) {
433
438
$ globalComposer = $ this ->createGlobalComposer ($ io , $ config , $ disablePlugins , $ disableScripts );
434
439
}
435
440
436
441
$ pm = $ this ->createPluginManager ($ io , $ composer , $ globalComposer , $ disablePlugins );
437
442
$ composer ->setPluginManager ($ pm );
438
443
439
- if (realpath ( $ config -> get ( ' home ' )) === $ cwd ) {
444
+ if ($ composer -> isGlobal () ) {
440
445
$ pm ->setRunningInGlobalDir (true );
441
446
}
442
447
0 commit comments