Script php artisan clear-compiled handling the pre-update-cmd event returned with an error (Laravel 4.1 upgrade)

87,208

Solution 1

Did you follow the upgrade procedure? Running composer update won't be enough. laravel.com/docs/upgrade

Solution 2

Maybe you can try this command:

composer install --no-scripts

Solution 3

Try to remove /bootstrap/compiled.php (I was in trouble downgrading Laravel 4.2 > 4.1)

Then try to composer update, it should work.

Good luck

Solution 4

Worked for me:

After updating composer.jsonper the upgrade guide, to get all updated repo's:

composer update --no-scripts

Then: composer dump-autoload -o

Then, I ran an update again so my pre/post update scripts can run: composer update

App loads in browser and all my tests pass again using 5.2. Hope this helps.

Solution 5

Try the following in your composer.json. There clear-compiled handling the pre-update-cmd event is your error you might clear it.

"scripts": {
    "pre-install-cmd": [
        "php artisan clear-compiled"
    ],
    "post-install-cmd": [
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ]
},

Try to run again the following command:

 php composer.phar update
Share:
87,208

Related videos on Youtube

user1072337
Author by

user1072337

Updated on July 09, 2022

Comments

  • user1072337
    user1072337 almost 2 years

    I recently tried upgrading from Laravel 4.0 to Laravel 4.1, and I am getting the follow error when running php composer.phar update:

    Script php artisan clear-compiled handling the pre-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]
    

    I am only requiring:

    "require": {
            "laravel/framework": "4.1.*",
            "way/generators": "2.*",
            "madewithlove/laravel-oauth2": "0.4.*"
        },
    

    Also, I received this before the error (even though I am running php 5.4.10 in my environment):

    phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
    phpseclib/phpseclib suggests installing pear-pear/PHP_Compat (Install PHP_Compat to get phpseclib working on PHP < 4.3.3.)
    d11wtq/boris suggests installing ext-readline (*)
    d11wtq/boris suggests installing ext-pcntl (*)
    Writing lock file
    Generating autoload files
    

    EDIT:

    Scripts being used in composer.json:

    "scripts": {
            "pre-install-cmd": [
                "php artisan clear-compiled"
            ],
            "post-install-cmd": [
                "php artisan optimize"
            ],
            "pre-update-cmd": [
                "php artisan clear-compiled"
            ],
            "post-update-cmd": [
                "php artisan optimize"
            ],
            "post-create-project-cmd": [
                "php artisan key:generate"
            ]
        },
    
    • user2094178
      user2094178 about 10 years
      Did you follow the upgrade procedure? Running composer update won't be enough. laravel.com/docs/upgrade
    • user1072337
      user1072337 about 10 years
      making the aforementioned changes in the upgrade fixed the problem. Thank you. If you would like to answer, I will give you the checkmark.
    • user2094178
      user2094178 about 10 years
      Ok, I'll answer, thank you.
    • Nanhe Kumar
      Nanhe Kumar almost 10 years
      if you are using ubuntu then sudo php5enmod mcrypt
  • user1072337
    user1072337 about 10 years
    After making this change (see edit above), I am still receiving the error: Script php artisan clear-compiled handling the pre-update-cmd event returned with an error [RuntimeException] Error Output:
  • Bmoeller
    Bmoeller almost 10 years
    I'll give a point for sending me in the right direction. I updated from 4.0 - 4.1 and never looked for update notes. Encountered the same issue as the poster and followed the update directions. Ran the update again and it worked.
  • Kryten
    Kryten almost 10 years
    Just an added note for anyone who might find this later --- the order of changes is important! The upgrade procedure calls for running composer update after changes are made. I was trying to run it first and running into this problem.
  • Rich Bradshaw
    Rich Bradshaw almost 10 years
    @Kryten what should I do if I did composer update before making changes?
  • Kryten
    Kryten almost 10 years
    @RichBradshaw I just went ahead ignored the errors, made the rest of the changes suggested in the upgrade instructions, then ran composer update at the end. It worked fine.
  • ρяσѕρєя K
    ρяσѕρєя K over 7 years
    This post isn't an actual attempt at answering the question. Please note StackOverflow doesn't work like a discussion forum, it is a Q&A site where every post is either a question or an answer to a question. Posts can also have comments - small sentences like this one - that can be used to critique or request clarification from an author. This should be either a comment or a new question
  • KhoPhi
    KhoPhi over 5 years
    Except this was the actual solution that helped in my case.
  • andromeda
    andromeda over 5 years
    Worked for me in Laravel 5.2
  • Rostyslav Pylypenko
    Rostyslav Pylypenko almost 5 years
    From 5.5 migration. "With recent improvements to PHP op-code caching, the optimize Artisan command is no longer needed. You should remove any references to this command from your deployment scripts as it will be removed in a future release of Laravel."