Composer - uncommited changes (symfony 2.1) - symfony

I am using symfony 2.1 with composer and I'm trying to run composer update
However, I keep getting "has uncommitted changes", I don't remember changing any of the files in the vendors dir and it comes up with almost every package!
I tried composer install to revert any changes, but it doesn’t seem to have an effect. If I delete the lock file and try an install, I get error messages like "symfony 2.1 requires symfony 2.1 -> symfony 2.1 satisfiable". It just doesn’t make sense.
If I delete the contents in vendors I get the same error messages and nothing installs.
Nothing I do seems to work. Is there a way to update with "force" regardless of "uncommitted changes"

You can use composer status -v. Here's how you can detect a file change in vendor/ using this command, and how to fix it.
First, we verify that no package is modified:
➜ SymfonyApp git:(master) ✗ composer status
No local changes
Then, we change a vendor file
➜ SymfonyApp git:(master) ✗ echo "modification" >> vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php
We then ask composer to tell us about modified vendor files (note the -v option, to see the modified files)
➜ SymfonyApp git:(master) ✗ composer status -v
You have changes in the following dependencies:
/Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony:
M src/Symfony/Component/HttpKernel/Kernel.php
We then reset the vendor git repository to set the files back to their original state.
➜ SymfonyApp git:(master) ✗ cd /Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony
➜ symfony git checkout .
➜ symfony cd -
~/Developer/SymfonyApp
Finally, we check that the files are not seen as modified anymore by composer.
➜ SymfonyApp git:(master) ✗ composer status -v
No local changes
Update: composer should now help you to handle this

You can also set the discard-changes to true in the config parameter of your composer.json file, see https://getcomposer.org/doc/06-config.md#discard-changes.
{
"name": "test",
"description": "Demonstrating concepts",
...
"config": {
"process-timeout": 1800,
"discard-changes" : true
},
...
}

Because this affected various projects sharing dependencies on one server, since for example a vender author would ask me to test quick changes before filing bugs and committing to their repo, I ran this to globally set discard-changes to true:
php composer.phar config -g discard-changes 1

Related

.composer is full ? No space left on device

When I deploy my project with capistrano (for Symfony), I have this error :
INFO [72050b7f] Running /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as dome#XX.XXX.XXX.XXX
DEBUG [72050b7f] Command: cd /var/www/dev/Dome/releases/20160812073355 && ( export SYMFONY_ENV="prod" ; /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
DEBUG [72050b7f] The disk hosting /var/www/.composer is full, this may be the cause of the following exception
DEBUG [72050b7f]
DEBUG [72050b7f]
[ErrorException]
ZipArchive::extractTo(): No space left on device
Can you help me ?
Just clear cache of composer use composer clear-cache
Reference
Use df -h to check all partitions (make sure to check the relevant partition, there can be multiple) and free space if possible.
Alternative options;
You can try changing the Composer home directory to another partition/location using the environment variable COMPOSER_HOME=/new/path.
You can disable the cache directory by using COMPOSER_CACHE_DIR=/dev/null.
The disk hosting /var/www/.composer is full.
The message is quite expressive, you have run out of ROM memory on your disk / partition, and can no longer download even source-code packages with composer.
I suggest you to either change of disk, or if it is a virtual partition, to improve the memory-size.
This does not seem to be related with either Capistrano, Symfony, Composer or PHP.
You have no permission to run the commands, if it works with sudo you did your deploy with root privilegies in the first place.

Handling composer install command in Travis CI environment to speed up the build time

I successfully created an example .travis.yml file and the build passes. However, it is a bit slow. The main cause is composer install and it takes up to 40 seconds.
Since my experience with Travis CI is 2 days old, I need someone with experience to tell me what is the better practise when it comes to using composer install in Travis environment? Under what block I should call it and what should be the command itself?
Note: I use Symfony projects so if there is something specific to this framework, please let me know.
I read some blog posts and went through example files in some open source projects and ended up confusing myself. Some use under before_script: and some install: etc. Also some use composer install, composer install --prefer-source --no-interaction --dev, travis_retry composer install --ignore-platform-reqs --no-interaction --prefer-source so on. My aim is to speed up the build time.
What's wrong with composer and your .travis.yml?
Composer update without PHP environment checking
PHP and Continuous Integration with Travis CI
so on
My own .travis.yml.
language: php
php:
- 5.6
env:
global:
- SOURCE_DIR=src
install:
- sudo apt-get update > /dev/null
- sudo apt-get install apache2 libapache2-mod-fastcgi > /dev/null
before_script:
- ...
- ...
- composer self-update
- composer install
- ...
- ...
script:
- bin/phpspec run --no-ansi --format=dot
- bin/behat --profile=default -f progress
- ...
- ...
There's no one right answer for which section the composer install belongs to IMO. Use what makes sense for you. I would put it in install.
Prefixing it with travis_retry is also a good idea if the command is prone to fail due to network issues. for example. It'll retry the same command a default number of 3 times. The command is only considered a failure if after all retry attempts the wrapped command still did not exit 0.
As for speeding up you build, I wouldn't bother for eliminating 40s from the build time. That said, you can have a look at caching the composer install directory. This would save a tarball of that dir after the builder finishes and try to get it from network storage at the beginning of the next build. That way only new.changed dependencies would be needed to install. Since that archive lives on network storage and not inside the container however, this might just not give you any actual speedup. Docs for caching

Symfony 2 -> Composer and CloudControl

I have a little problem to setup Symfony 2 on Cloudcontrol,
I followed the instructions and installed a Symfony 2 framework, changed the document root and so on.
Now when I try to push the changes to server server, it loads the dependencies from the composer.json and then it failed with a message :
[RuntimeException]
Could not scan for classes inside "/srv/tmp/builddir/code/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs" which does not appear to be a file nor a folder
This file is a vendor package, loaded from composer.
I have the same effect with a default composer.json file from a sample project (SF2)
Localy it works very well!
Can some one give me a hint ?
Got same error after setting "minimum-stability":"dev" and running composer update.
for unknown reason symfony/symfony (dev-master ...) kept failing to download from source thus was being loaded from cache.
what worked for me was a mix of previous answers:
$ rm -rf vendor/symfony
$ composer clearcache
$ composer install
Sometimes I had to clean composer cache to remove strange errors, usually it's in
/home/user/.composer/cache
You can also try to update composer with
php composer.phar self-update
I hope it runs for you.
I had the exact same error in my development directory.
What fixed it was :
$ rm -rf vendor/symfony
$ php composer.phar install
It reinstalled symfony/symfony, symfony/icu, symfony/assetic-bundle, symfony/monolog-bundle and symfony/swiftmailer-bundle and now everything works !

Not a git repository error when updating via Composer

I'm trying to update my Symfony 2 project from 2.1.4 to 2.1.7 using composer and run php composer.phar update as normal, after updating a few dependencies I receive the following error:
[RuntimeException]
Failed to clone http://github.com/fabpot/Twig-extensions via git, https
and http protocols, aborting.
- git://github.com/fabpot/Twig-extensions
fatal: Not a git repository (or any of the parent directories): .git
- https://github.com/fabpot/Twig-extensions
fatal: Not a git repository (or any of the parent directories): .git
- http://github.com/fabpot/Twig-extensions
fatal: Not a git repository (or any of the parent directories): .git
I've checked the URL and can confirm that it exists, I'm also able to git clone it without any issues from the same CLI.
What's odd is if I run php composer.phar update twig/extensions separately it seems to update without a problem.
This typically happens if you have an old symfony copy that shipped with the vendors installed as git repos but with the git repos removed. To fix it you should just remove the vendor directory so they will reinstall from scratch as git clones or as zip archives, but without any previous assumptions.
Note that currently, I experience a similar issue while using composer with hhvm and PHP 7.
[RuntimeException]
Failed to execute git checkout 'hash' -- && git reset --hard 'hash' --
fatal: Not a git repository (or any of the parent directories): .git
The error appears depending on the composer.json not always but rather regularly. I switch off hhvm to get it working.

Symfony2 updating bootstrap.php.cache

Recently I started a project in Symfony2 from the BETA version available on symfony.com
After a while, I needed to upgrade to the master branch, so I retrieved the latest from github and switched it in vendor/symfony.
However, my bootstrap.php.cache and bootstrap_cache.php.cache are not upgraded, which has generated errors.
I tried clearing the symfony cache, to no avail.
How can I update these files to correspond to my project?
In the 2.0 release the original file is here:
./vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
Edit: in release 2.3 the file is here
vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
If you run the composer update command you will also update your project dependencies which is not the desired behaviour here. If you do that you'll have to test the new changes to see if they do affect your application somehow.
So if you just want to rebuild your bootstrap cache file then I suggest you run the post-update-cmd command.
Therefore you should use:
composer run-script post-update-cmd
which in my case executes the following scripts (see composer.json):
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrapSass"
]
}
Please consider that you can also create a new set of scripts in there to just rebuild the bootstrap file and clears the cache without installing the assets and so on:
"scripts": {
"reset-bootstrap-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
]
}
and then... composer run-script reset-bootstrap-cmd
In the latest 2.1.0-DEV, the actual script is here:
./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
I'm using Symfony Standard 2.0.9 (without Vendors).
To update bootstrap.php.cache, just run
php bin/vendors update
This will update all vendors (including Symfony itself) and always call that build_bootstrap.php script for you.
Have you tried running:
php bin/build_bootstrap.php
This will regenerate the bootstrap files
You might prefer to use composer install which "re-installs" the system to the state definied in the composer.lock file and generates autoloads and bootstrap.php.cache. Using composer update updates all packages and changes the state of your system.
I feel like the build_bootstrap script is always changing location :)
So, if you are working with several Symfony versions and don't know where the build_bootstrap is, this will do the trick (Linux/Mac only):
$ cd vendor/
$ find . -name build_bootstrap.php
i couldnt fix a problem on my bootstrap cache, nor update it . i was getting alot of this
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: Invalid argument supplied for foreach() in /home/sites/fuji/app/bootstrap.php.cache line 2870
Script
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-update-cmd event terminated with an exception
although they were great suggestions, and i did try the rebuilding of bootstrap cache file after backing it up, and to run composer update these still gave me the same problem.
Solution for me:
i shelled into the pc with the site files on it,
rm -rf app/cache/* -R removed everything inside the cache directory then i was able to run both composer update, AND clear cache etc.. with no problems.
Search for where the "build_bootstrap.php" located at.
for my case in Symfony3.4
php ./vendor/sensio/distribution-bundle/Resources/bin/build_bootstrap.php

Resources