Ryan Bowden
Ryan Bowden

Reputation: 171

Composer scripts no longer running

So our websites we have composer set, And after it has got the packages we run some commands.

"scripts": {
    "post-install-cmd": [
        "php -r \"shell_exec('cp -rf sourcefiles/. source/.');\"",
        "php -r \"shell_exec('rm -rf sourcefiles');\""
    ]
}

These run find with version 2016-02-24_11-44-07-45f6b37

But when I run the self updater to get the latest version it brakes the code and no longer works, even though nothing has changed.

This is a cause for concern as it means we can no longer update our composer. Any idea why is has broke are we doing something wrong?

Many Thanks.

Upvotes: 2

Views: 477

Answers (2)

Ryan Bowden
Ryan Bowden

Reputation: 171

Someone on github told the the problem,

So only run the script on "post-install-cmd" this works pre 1.0 now you need to run the scripts on "post-install-cmd" and "post-update-cmd" if a lock file exists it runs the update command.

So the code now looks like this:

"scripts": {
    "post-install-cmd": [
        "cp -rf sourcefiles/. source/.", 
        "rm -rf sourcefiles"
    ],
    "post-update-cmd": [
        "cp -rf sourcefiles/. source/.", 
        "rm -rf sourcefiles"
    ]
}

Thank you for helping remove the PHP dependency

Upvotes: 4

Sven
Sven

Reputation: 70853

The funny thing about your scripts is: The real shell command is cp -rf sourcefiles/. source/., and you are wrapping this into a call to the PHP function shell_exec(), and because this function cannot be called without the help of PHP, you pass this source code to PHP on the shell.

Alternative script suggestion:

"scripts": {
    "post-install-cmd": [
        "cp -rf sourcefiles/. source/.",
        "rm -rf sourcefiles"
    ]
}

However, you have to provide more details on the error, any message you get etc.

Upvotes: 1

Related Questions