问题
I have installed composer globally on ubuntu 14.04. When I run composer --version it works with the following output
Composer version 1.0-dev (45b1f356c24d87788a339f6a50d6d78bef464c47) 2015-02-27 14:31:27
But when I run the following command composer update -vvv
It gives the following error
Failed to initialize global composer: Composer could not find the config file: /home/enamul/.composer/composer.json
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
I have no idea, why this is happening. Can anyone help me with that.
Thanks
回答1:
Just put an empty JSON object into your global config.
echo "{}" > ~/.composer/composer.json
Composer will merge this configuration with your project's composer.json when you run the install and update commands.
From the docs https://getcomposer.org/doc/03-cli.md#composer-home
回答2:
To debug this, you should do on the command line:
cd /opt/lampp/htdocs/myproject
ls -al
cat composer.json
All these commands should show the expected thing. I'd expect the directory listing to show the composer.json file being present and having correct access rights for the user you are running as.
composer update
I have no idea why composer would ever fail, but from my experience it does a pretty good job doing what its supposed to do. Failure usually is caused by minor oversights of obvious things.
来源:https://stackoverflow.com/questions/28785229/composer-update-vvv-is-not-working