15

Here is the error I am getting:

Script php artisan optimize handling the post-update-cmd event returned with an error

[RuntimeException]  
Error Output:

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]

This shows after:

Writing lock file
Generating autoload files

I tried to delete all my folders in my vendor folder. But that did not change anything.

I am using MAMP server on my Mac OS X.

PHP Version 5.4.10

mcrypt 2.5.8

I just tried "sudo composer update --verbose" and I got this error:

sudo composer update --verbose
Password:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
Script php artisan optimize handling the post-update-cmd event returned with an error

  [RuntimeException]  
  Error Output:
    Exception trace:
     () at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:148
     Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:107
 Composer\EventDispatcher\EventDispatcher->dispatchCommandEvent() at phar:///usr/bin/composer/src/Composer/Installer.php:289
 Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/UpdateCommand.php:118
 Composer\Command\UpdateCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:897
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:117
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:83
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:43
 require() at /usr/bin/composer:15

Here is the error I found in my PHP error logs:

[04-Nov-2013 20:45:44 Europe/Berlin] PHP Fatal error:  Class 'Patchwork\Utf8\Bootup' not found in /Applications/MAMP/htdocs/-----/bootstrap/autoload.php on line 46

I just tried to test my composer:

sudo composer diagnose
Password:
Checking platform settings: OK
Checking http connectivity: OK
Checking composer.json: FAIL
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Name "andrew13/Laravel-4-Bootstrap-Starter-Site" does not match the best practice (e.g. lower-cased/with-dashes). We suggest using "andrew13/laravel-4-bootstrap-starter-site" instead. As such you will not be able to submit it to Packagist.
Checking disk free space: OK
Checking composer version: OK

Just applied the recommendation in the error message from the last command. Now everything is showing as OK.

I just tried this:

curl -sS https://getcomposer.org/installer | php -- --check
#!/usr/bin/env php
All settings correct for using Composer

I am now getting new errors in my PHP Error logs:

[05-Nov-2013 05:45:45 Europe/Berlin] PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class config does not exist' in /Applications/MAMP/htdocs/---/bootstrap/compiled.php:165
Stack trace:
#0 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(165): ReflectionClass->__construct('config')
#1 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(142): Illuminate\Container\Container->build('config', Array)
#2 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(444): Illuminate\Container\Container->make('config', Array)
#3 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(233): Illuminate\Foundation\Application->make('config')
#4 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(3151): Illuminate\Container\Container->offsetGet('config')
#5 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(103): Illuminate\Exception\ExceptionServiceProvider->Illuminate\Exception\{closure}(Object(Illuminate\Foundation\Application))
#6 /Applications/MAMP/htdocs/---/bootstrap/compiled.php(163): Illuminate\Container\Container->Illum in /Applications/MAMP/htdocs/---/bootstrap/compiled.php on line 165
Falko
  • 17,076
  • 13
  • 60
  • 105
jnbdz
  • 4,863
  • 9
  • 51
  • 93
  • The exception message is missing from the verbose output, pretty hard to say anything without it. – Fleshgrinder Nov 04 '13 at 19:51
  • I just added more information. Is there something else missing? I can't think of anything else. – jnbdz Nov 04 '13 at 20:00
  • Okay, the runtime exception has no message as it seems but the log entry is clear. Composer is unable to autoload the `Patchwork\Utf8\Bootup` file. This can have various reasons. My guess, the vendor's composer file has incorrect autoload settings. – Fleshgrinder Nov 04 '13 at 20:02
  • I never touch these settings. I just tried to update my Lavarel 4 setup. – jnbdz Nov 04 '13 at 20:09
  • Sure, but it seems that a composer configuration from one of the projects is wrong. Or a file is missing from the file system. – Fleshgrinder Nov 04 '13 at 20:15
  • I just did composer diagnose and I saw they were two errors in composer.json. The strange thing is that I never encountered any problems in the past. I will try to debug it and re-test. – jnbdz Nov 04 '13 at 20:18
  • I just updated my question. I did some tests and it shows that my settings for composer are OK. – jnbdz Nov 04 '13 at 20:25
  • I added `chmod +w path/to/vendor` and it worked like a charm – Sarel Jul 03 '14 at 18:30
  • seems like this is just a bad error message and can show up due to any number of reasons. the `composer dump-autoload` advice below seems most likely to solve things. i'm having this problem too though, about to try that out myself. – Randy L Sep 28 '15 at 21:11

6 Answers6

27

I believe this error results from not being able to find mcrypt.

Script php artisan optimize handling the post-update-cmd event returned with an error

Apparently it is not quite that easy to install mcrypt.

  1. Install the php5-mcrypt package, or verify that it has been installed correctly.

    sudo apt-get install php5-mcrypt
    
  2. Check whether mcrypt has been installed and enabled for PHP:

    php --ri mcrypt
    
  3. You're done if it says:

    mcrypt support => enabled
    

    Otherwise, continue if it says:

    Extension 'mcrypt' not present.
    
  4. Verify that mcrypt.ini is present in PHP's mods-available directory.

    ls /etc/php5/mods-available/mcrypt.ini
    
  5. If it says No such file or directory, create a symbolic link from mcrypt.ini to PHP's mods-available directory.

    sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
    
  6. Enable the mod.

    sudo php5enmod mcrypt
    
  7. Restart apache.

    sudo service apache2 restart
    
  8. Check again whether mcrypt is enabled.

    php --ri mcrypt
    

The final steps were inspired by Vuk Stanković.

Community
  • 1
  • 1
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
9

Okay, did some further research with Google and it seems that this has to do with the autoload caching from Composer. There are various ways on how you can solve this.

composer dump-autoload

This would re-create the autoload stuff for you and it should solve your problem for now.

If this doesn't help, try deleting everything and re-install fresh: [ref]

rm -rf /path/to/composer.lock /path/to/vendor/
composer install

This would re-create just about everything.

Fleshgrinder
  • 15,703
  • 4
  • 47
  • 56
  • Nop, not working. I get: Script php artisan optimize handling the post-install-cmd event returned with an error – jnbdz Nov 04 '13 at 22:43
  • I deleted the composer.lock found at the root of my web app but I did not remove the composer.lock inside some of the vendors. – jnbdz Nov 04 '13 at 23:06
  • Seems like a very common problem (e.g. stackoverflow.com/questions/18127347/). But it also seems like there's no real solution that works for everyone. You should post your question in the artisan support forum (GitHub or wherever that is). – Fleshgrinder Nov 04 '13 at 23:08
3

It looks like your laravel install did not run correctly and since part of the composer.json runs the php artisan clear-compiled and php artisan optimize if your laravel application is not working then composer will fail.

Try running your composer update without invoking the Laravel scripts.

php composer update --no-scripts

After that you can either run the commands from the scripts block in your composer.json manually. Else you can just run a standard

php composer update

again which will run the scripts for you.

Hailwood
  • 89,623
  • 107
  • 270
  • 423
  • I tried the first command but I got this error: "touch(): Utime failed: Permission denied". I have no idea what this is. – jnbdz Nov 06 '13 at 23:13
  • I deleted composer.lock and the folder vendor. And I tried the first command and it worked. But the second command gives me: "Script php artisan optimize handling the post-update-cmd event returned with an error" – jnbdz Nov 07 '13 at 00:14
  • Here is a new error I am getting: PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class config does not exist' in /Applications/MAMP/htdocs/---/bootstrap/compiled.php:165 Stack trace: – jnbdz Nov 07 '13 at 01:55
  • To see more just look at the end of my question. – jnbdz Nov 07 '13 at 03:28
  • do you have write permissions on that directory? – Hailwood Nov 07 '13 at 03:44
  • The directory that your composer.json file is in, also the vendor directory (and children). – Hailwood Nov 07 '13 at 21:11
  • I solved the "touch(): Utime failed: Permission denied" by executing sudo rm -rf ~/.composer/ This seems to be composer's cache directory. – totas Feb 09 '14 at 13:15
0

To fix this you need to install mcrypt.
In ubuntu execute the following command:

sudo apt-get install php5-mcrypt

Then update composer:

composer update 
Florent
  • 12,310
  • 10
  • 49
  • 58
BM2ilabs
  • 522
  • 6
  • 11
0

Another solution for me, setting xdebug.scream = 1 gives problem:

1) Find xdebug configuration file.

$ sudo find / -name xdebug.ini

2) Edit file using any text editor.

$ sudo vi /your_path/xdebug.ini

3) Set xdebug.scream = 0

4) Reload server

$ sudo service apache2 reload
Alphapico
  • 2,893
  • 2
  • 30
  • 29
0

I had a similar issue when trying to run composer update and none of the solutions above had worked. It turns out I had 2 require sections in my composer.json which is actually wrong.

"require": {
    "laravel/framework": "4.1.*"
},
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "stable",
"require": {
    "barryvdh/laravel-ide-helper": "1.*",
    "zizaco/confide": "3.2.x",
    "laravelbook/ardent": "dev-master",
    "zizaco/entrust": "dev-master"
},
"require-dev": {
    "way/generators": "2.*",
    "fzaninotto/faker": "1.3.*@dev"
}

Combining the two as below solved my issue.

"require": {
    "laravel/framework": "4.1.*",
    "barryvdh/laravel-ide-helper": "1.*",
    "zizaco/confide": "3.2.x",
    "laravelbook/ardent": "dev-master",
    "zizaco/entrust": "dev-master"
},

If you still have a problem, try deleting the composer.lock and the vendor directory and run

mv ~/.composer/cache ~/.composer/cache.bak

To clear the composer cache and finally run

sudo composer install

This should solve the issue.

Mohamed Azher
  • 411
  • 5
  • 3