【问题标题】:Composer post-install-cmd not running with git hookComposer post-install-cmd 未使用 git hook 运行
【发布时间】:2015-07-31 21:27:44
【问题描述】:

由于某种原因,当 composer 从我的部署挂钩运行时,我的 post-install-cmd 似乎没有运行。

如果我之后立即通过 ssh 在盒子上运行composer install,那么安装过程会再次运行,但会运行安装后脚本。

为了清楚起见,我要运行的是“jakoch/phantomjs-installer”。

如您所见,我的作曲家已经准备就绪。

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*",
        "jakoch/phantomjs-installer": "1.9.8",
        "illuminate/html": "~5.0",
        "guzzlehttp/guzzle": "~5.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database",
            "app/libraries",
            "app/Models"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize",
            "PhantomInstaller\\Installer::installPhantomJS"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize",
            "PhantomInstaller\\Installer::installPhantomJS"
        ],
        "post-create-project-cmd": [
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

post 接收钩子的输出运行 composer install 如下:

remote: Checking composer.json for Composer dependency... 
remote: Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/var/lib/openshift/5555f3255973ca3b9c00018a/php/usr/bin/composer self-update" to get the latest version.
remote: Loading composer repositories with package information
remote: Installing dependencies (including require-dev) from lock file
remote:   - Installing react/promise (v2.2.0)
remote:     Loading from cache
remote: 
remote:   - Installing guzzlehttp/streams (3.0.0)
remote:     Loading from cache
remote: 
remote:   - Installing guzzlehttp/ringphp (1.0.7)
remote:     Loading from cache
remote: 
remote:   - Installing guzzlehttp/guzzle (5.2.0)
remote:     Loading from cache
remote: 
remote:   - Installing vlucas/phpdotenv (v1.1.0)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/var-dumper (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/translation (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/security-core (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/routing (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/process (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/http-foundation (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/event-dispatcher (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing psr/log (1.0.0)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/debug (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/http-kernel (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/finder (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/console (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing swiftmailer/swiftmailer (v5.4.0)
remote:     Loading from cache
remote: 
remote:   - Installing nikic/php-parser (v1.3.0)
remote:     Loading from cache
remote: 
remote:   - Installing jakub-onderka/php-console-color (0.1)
remote:     Loading from cache
remote: 
remote:   - Installing jakub-onderka/php-console-highlighter (v0.3.1)
remote:     Loading from cache
remote: 
remote:   - Installing dnoegel/php-xdg-base-dir (0.1)
remote:     Loading from cache
remote: 
remote:   - Installing psy/psysh (v0.4.4)
remote:     Loading from cache
remote: 
remote:   - Installing nesbot/carbon (1.19.0)
remote:     Loading from cache
remote: 
remote:   - Installing mtdowling/cron-expression (v1.0.4)
remote:     Loading from cache
remote: 
remote:   - Installing monolog/monolog (1.13.1)
remote:     Loading from cache
remote: 
remote:   - Installing league/flysystem (1.0.3)
remote:     Loading from cache
remote: 
remote:   - Installing jeremeamia/superclosure (2.1.0)
remote:     Loading from cache
remote: 
remote:   - Installing ircmaxell/password-compat (v1.0.4)
remote:     Loading from cache
remote: 
remote:   - Installing doctrine/inflector (v1.0.1)
remote:     Loading from cache
remote: 
remote:   - Installing danielstjules/stringy (1.9.0)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/filesystem (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing classpreloader/classpreloader (1.3.0)
remote:     Loading from cache
remote: 
remote:   - Installing laravel/framework (v5.0.31)
remote:     Loading from cache
remote: 
remote:   - Installing illuminate/html (v5.0.0)
remote:     Loading from cache
remote: 
remote:   - Installing jakoch/phantomjs-installer (1.9.8)
remote:     Loading from cache
remote: 
remote:   - Installing phpdocumentor/reflection-docblock (2.0.4)
remote:     Loading from cache
remote: 
remote:   - Installing symfony/yaml (v2.6.7)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/recursion-context (1.0.0)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/exporter (1.2.0)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/diff (1.3.0)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/comparator (1.1.1)
remote:     Loading from cache
remote: 
remote:   - Installing doctrine/instantiator (1.0.4)
remote:     Loading from cache
remote: 
remote:   - Installing phpspec/prophecy (v1.4.1)
remote:     Loading from cache
remote: 
remote:   - Installing phpspec/php-diff (v1.0.2)
remote:     Loading from cache
remote: 
remote:   - Installing phpspec/phpspec (2.2.0)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/php-token-stream (1.4.1)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/version (1.0.5)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/global-state (1.0.0)
remote:     Loading from cache
remote: 
remote:   - Installing sebastian/environment (1.2.2)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/php-text-template (1.2.0)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/phpunit-mock-objects (2.3.1)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/php-timer (1.0.5)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/php-file-iterator (1.4.0)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/php-code-coverage (2.0.16)
remote:     Loading from cache
remote: 
remote:   - Installing phpunit/phpunit (4.6.6)
remote:     Loading from cache
remote: 
remote: symfony/var-dumper suggests installing ext-symfony_debug ()
remote: symfony/translation suggests installing symfony/config ()
remote: symfony/security-core suggests installing symfony/expression-language (For using the expression voter)
remote: symfony/security-core suggests installing symfony/validator (For using the user password constraint)
remote: symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
remote: symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
remote: symfony/routing suggests installing symfony/expression-language (For using expression matching)
remote: symfony/event-dispatcher suggests installing symfony/dependency-injection ()
remote: symfony/http-kernel suggests installing symfony/browser-kit ()
remote: symfony/http-kernel suggests installing symfony/class-loader ()
remote: symfony/http-kernel suggests installing symfony/config ()
remote: symfony/http-kernel suggests installing symfony/dependency-injection ()
remote: psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
remote: monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
remote: monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
remote: monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
remote: monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
remote: monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
remote: monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
remote: monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
remote: monolog/monolog suggests installing videlalvaro/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
remote: league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
remote: league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
remote: league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
remote: league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
remote: league/flysystem suggests installing league/flysystem-copy (Allows you to use Copy.com storage)
remote: league/flysystem suggests installing league/flysystem-dropbox (Allows you to use Dropbox storage)
remote: league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
remote: league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
remote: league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
remote: league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
remote: league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
remote: league/flysystem suggests installing predis/predis (Allows you to use Predis for caching)
remote: laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (~2.4).)
remote: laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.4).)
remote: laravel/framework suggests installing iron-io/iron_mq (Required to use the iron queue driver (~1.5).)
remote: laravel/framework suggests installing league/flysystem-aws-s3-v2 (Required to use the Flysystem S3 driver (~1.0).)
remote: laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
remote: laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (~3.0).)
remote: laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (~1.0).)
remote: phpdocumentor/reflection-docblock suggests installing dflydev/markdown (~1.0)
remote: phpdocumentor/reflection-docblock suggests installing erusev/parsedown (~1.0)
remote: phpspec/phpspec suggests installing phpspec/nyan-formatters (~1.0 – Adds Nyan formatters)
remote: sebastian/global-state suggests installing ext-uopz (*)
remote: phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
remote: phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)

但从不安装实际文件,我需要手动 ssh 并运行composer install,这样可以:

[teampro-propduck.rhcloud.com repo]\> composer install
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/var/lib/openshift/5555f3255973ca3b9c00018a/php/usr/bin/composer self-update" to get the latest version.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
Generating optimized class loader
Compiling common classes
  - Installing phantomjs (1.9.8)
    Loading from cache

【问题讨论】:

  • 嘿 Ryk,我不确定为什么钩子不会触发 phantomjs-installer。您能否以详细模式(从 Git 挂钩)运行 Composer 以获取有关正在发生的事情的更多详细信息:composer install -vvv
  • 不幸的是,openshift 似乎使用标记文件调用了作曲家,所以我无法控制钩子上不起作用的输出。到目前为止的解决方法是在我可以控制的钩子的稍后阶段调用composer update。似乎在工作,但似乎太浪费了!
  • 啊,好的。是的,运行composer update 是不必要的额外步骤。 -- 猜测:php artisan optimize 被执行了吗?这是1.9.8 问题吗(尝试提高到2.0.0) - 2.0.0 不会安装 Phantom,因为二进制文件没有发布,但至少您可以测试安装程序是否已执行。 - 我无法重现该问题,并且没有调试信息,我们被卡住了。随时在github.com/jakoch/phantomjs-installer 上打开错误报告,也许其他人遇到或遇到同样的问题并且能够提供帮助。谢谢,延斯
  • 是的,我同意,我会尝试等到 linux 2.0.0 版本发布,然后看看会发生什么。解决方法现在很好,只需为我的部署脚本增加一分钟(不是世界末日)。当我真正了解它时,我当然会更新它。

标签: git laravel phantomjs composer-php


【解决方案1】:

目前的答案是稍后在部署挂钩中运行一个额外的composer update。所以基本上它运行了两次。

这绝对是一种解决方法,而不是修复,但可能会让人感动,而不是我花了 3 天时间完全卡在它上面。

如果我得到任何进一步的适当修复,将更新。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 2019-01-23
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    • 2013-10-08
    • 2017-08-14
    相关资源
    最近更新 更多