【问题标题】:doctrine/dbal not getting installed in Heroku没有在 Heroku 中安装学说/dbal
【发布时间】:2017-05-03 14:48:58
【问题描述】:

我正在 Heroku 上运行一个 Laravel 项目。为了运行将更改列类型的迁移,我需要安装学说/dbal 包。我将"doctrine/dbal": "^2.5" 行放在"require" 对象的composer.json 中。

当我将更改推送到 Heroku 时,它会显示该行。

- Installing doctrine/dbal (v2.5.5)
  Downloading: 100%

在那之后,当我运行heroku run composer show doctrine/dbal 时,它正在显示。

[InvalidArgumentException]
Package doctrine/dbal not found

在那之后我也跑了几次heroku run composer update。这是我的命令的完整日志。

C:\xampp\htdocs\jem\red-arrow (master) (red-arrow@0.0.1)
λ heroku run composer update
Running composer update on red-arrow... up, run.9733 (Free)
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing symfony/polyfill-mbstring (v1.2.0)
- Installing symfony/polyfill-mbstring (v1.3.0)
    Downloading: 100%

- Removing symfony/var-dumper (v3.1.4)
- Installing symfony/var-dumper (v3.1.8)
    Downloading: 100%

- Removing symfony/translation (v3.1.4)
- Installing symfony/translation (v3.1.8)
    Downloading: 100%

- Removing symfony/routing (v3.1.4)
- Installing symfony/routing (v3.1.8)
    Downloading: 100%

- Removing symfony/process (v3.1.4)
- Installing symfony/process (v3.1.8)
    Downloading: 100%

- Removing symfony/http-foundation (v3.1.4)
- Installing symfony/http-foundation (v3.1.8)
    Downloading: 100%

- Removing symfony/event-dispatcher (v3.1.4)
- Installing symfony/event-dispatcher (v3.2.1)
    Downloading: 100%

- Removing psr/log (1.0.0)
- Installing psr/log (1.0.2)
    Downloading: 100%

- Removing symfony/debug (v3.1.4)
- Installing symfony/debug (v3.1.8)
    Downloading: 100%

- Removing symfony/http-kernel (v3.1.4)
- Installing symfony/http-kernel (v3.1.8)
    Downloading: 100%

- Removing symfony/finder (v3.1.4)
- Installing symfony/finder (v3.1.8)
    Downloading: 100%

- Removing symfony/console (v3.1.4)
- Installing symfony/console (v3.1.8)
    Downloading: 100%

- Removing swiftmailer/swiftmailer (v5.4.3)
- Installing swiftmailer/swiftmailer (v5.4.4)
    Downloading: 100%

- Removing paragonie/random_compat (v2.0.2)
- Installing paragonie/random_compat (v2.0.4)
    Downloading: 100%

- Removing ramsey/uuid (3.5.0)
- Installing ramsey/uuid (3.5.2)
    Downloading: 100%

- Removing nikic/php-parser (v2.1.1)
- Installing nikic/php-parser (v3.0.2)
    Downloading: 100%

- Removing psy/psysh (v0.7.2)
- Installing psy/psysh (v0.8.0)
    Downloading: 100%

- Removing monolog/monolog (1.21.0)
- Installing monolog/monolog (1.22.0)
    Downloading: 100%

- Removing league/flysystem (1.0.27)
- Installing league/flysystem (1.0.32)
    Downloading: 100%

- Removing symfony/polyfill-util (v1.2.0)
- Installing symfony/polyfill-util (v1.3.0)
    Downloading: 100%

- Removing symfony/polyfill-php56 (v1.2.0)
- Installing symfony/polyfill-php56 (v1.3.0)
    Downloading: 100%

- Removing jeremeamia/superclosure (2.2.0)
- Installing jeremeamia/superclosure (2.3.0)
    Downloading: 100%

- Removing classpreloader/classpreloader (3.0.0)
- Installing classpreloader/classpreloader (3.1.0)
    Downloading: 100%

- Removing laravel/framework (v5.3.9)
- Installing laravel/framework (v5.3.28)
    Downloading: 100%

- Installing doctrine/lexer (v1.0.1)
    Downloading: 100%

- Installing doctrine/collections (v1.3.0)
    Downloading: 100%

- Installing doctrine/cache (v1.6.1)
    Downloading: 100%

- Installing doctrine/annotations (v1.3.0)
    Downloading: 100%

- Installing doctrine/common (v2.6.2)
    Downloading: 100%

- Installing doctrine/dbal (v2.5.5)
    Downloading: 100%

- Installing fzaninotto/faker (v1.6.0)
    Downloading: 100%

- Installing hamcrest/hamcrest-php (v1.2.2)
    Downloading: 100%

- Installing mockery/mockery (0.9.6)
    Downloading: 100%

- Installing symfony/yaml (v3.2.1)
    Downloading: 100%

- Installing sebastian/version (2.0.1)
    Downloading: 100%

- Installing sebastian/resource-operations (1.0.0)
    Downloading: 100%

- Installing sebastian/recursion-context (2.0.0)
    Downloading: 100%

- Installing sebastian/object-enumerator (2.0.0)
    Downloading: 100%

- Installing sebastian/global-state (1.1.1)
    Downloading: 100%

- Installing sebastian/exporter (2.0.0)
    Downloading: 100%

- Installing sebastian/environment (2.0.0)
    Downloading: 100%

- Installing sebastian/diff (1.4.1)
    Downloading: 100%

- Installing sebastian/comparator (1.2.2)
    Downloading: 100%

- Installing doctrine/instantiator (1.0.5)
    Downloading: 100%

- Installing phpunit/php-text-template (1.2.1)
    Downloading: 100%

- Installing phpunit/phpunit-mock-objects (3.4.3)
    Downloading: 100%

- Installing phpunit/php-timer (1.0.8)
    Downloading: 100%

- Installing phpunit/php-file-iterator (1.4.2)
    Downloading: 100%

- Installing sebastian/code-unit-reverse-lookup (1.0.0)
    Downloading: 100%

- Installing phpunit/php-token-stream (1.4.9)
    Downloading: 100%

- Installing phpunit/php-code-coverage (4.0.3)
    Downloading: 100%

- Installing webmozart/assert (1.2.0)
    Downloading: 100%

- Installing phpdocumentor/reflection-common (1.0)
    Downloading: 100%

- Installing phpdocumentor/type-resolver (0.2.1)
    Downloading: 100%

- Installing phpdocumentor/reflection-docblock (3.1.1)
    Downloading: 100%

- Installing phpspec/prophecy (v1.6.2)
    Downloading: 100%

- Installing myclabs/deep-copy (1.5.5)
    Downloading: 100%

- Installing phpunit/phpunit (5.7.4)
    Downloading: 100%

- Installing symfony/css-selector (v3.1.8)
    Downloading: 100%

- Installing symfony/dom-crawler (v3.1.8)
    Downloading: 100%

sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.4.0)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.

C:\xampp\htdocs\jem\red-arrow (master) (red-arrow@0.0.1)
λ heroku run composer show doctrine/dbal
Running composer show doctrine/dbal on red-arrow... up, run.6084 (Free)


[InvalidArgumentException]
Package doctrine/dbal not found


show [--all] [-i|--installed] [-p|--platform] [-a|--available] [-s|--self] [-N|--name-only] [-P|--path] [-t|--tree] [-l|--latest] [-o|--outdated] [-D|--direct] [--] [<package>] [<version>]

git repo 链接:https://github.com/Jimut/red-arrow

Heroku 应用链接:http://red-arrow.herokuapp.com/

【问题讨论】:

  • 不要费心在 Heroku 上运行 composer update。编译 slug 后对本地文件系统所做的任何更改will be lost as soon as your Dyno cycles。 (在您的服务器上运行composer update 也不是一个好主意;请改用composer install。)heroku run composer show 会生成您期望的输出吗?根据该命令的执行位置,它可能根本找不到您的本地 vendor/ 目录(这没关系)。唯一重要的是您的代码可以找到您的库。
  • 哦!我得到了它。问题的发生是因为我只是将"doctrine/dbal": "^2.5""require-dev" 剪切粘贴到"require" 并且没有更新锁定文件。 Heroku 在 git push 之后运行 composer install 而不是 composer update。所以这个包没有被安装。我应该写一个答案还是删除问题?
  • 这取决于你,但请考虑answering your own question and then accepting your answer。这样其他用户就可以从您的发现中受益。
  • @Chris 非常感谢。

标签: laravel heroku composer-php dbal


【解决方案1】:

所以,问题是 composer.lock 在我将 repo 推送到 Heroku 之前没有更新。

Heroku 仅在 git push 之后运行 composer install,它读取锁定文件以安装软件包。正如克里斯在 cmets 中指出的那样

不要费心在 Heroku 上运行 composer update。编译 slug 后对本地文件系统所做的任何更改都将在 Dyno 循环后丢失。

所以最好的做法是,在本地文件系统中编辑 composer.json 后,始终运行composer update,然后运行git push

我将 "doctrine/dbal": "^2.5""require-dev" 移动到 "require" 并且在推送之前没有运行 composer update,这就是问题的原因。

【讨论】:

    猜你喜欢
    • 2017-11-24
    • 2015-02-28
    • 2016-08-25
    • 1970-01-01
    • 2020-12-28
    • 2013-05-31
    • 1970-01-01
    • 2021-04-13
    • 2015-09-06
    相关资源
    最近更新 更多