php - 运行 composer install 时处理 "the requested PHP extension pdo_sqlite is missing from your system. "

标签 php jenkins composer-php

我在 Jenkins 上运行 composer install 时遇到困难。

我有一个 Jenkins 作业,我需要为其运行 composer install。我已经安装了 php7.2 和 Composer 。当我运行命令时,出现以下错误:

composer 安装

  Problem 1
- teamtnt/tntsearch v1.3.2 requires ext-pdo_sqlite * -> the requested PHP extension pdo_sqlite is missing from your system.
- teamtnt/tntsearch v1.3.2 requires ext-pdo_sqlite * -> the requested PHP extension pdo_sqlite is missing from your system.
- Installation request for teamtnt/tntsearch v1.3.2 -> satisfiable by teamtnt/tntsearch[v1.3.2].

所以我使用以下命令安装 sqlite:sudo apt-get install php7.2-sqlite3

在此之后,我收到了额外的警告,但错误仍然存​​在。

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite.so' 
(tried: /usr/lib/php/20170718/pdo_sqlite.so (/usr/lib/php/20170718/pdo_sqlite.so: 
undefined symbol: sqlite3_column_table_name), /usr/lib/php/20170718/pdo_sqlite.so.so
(/usr/lib/php/20170718/pdo_sqlite.so.so: cannot open shared object file: 
No such file or directory)) in Unknown on line 0
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1
- teamtnt/tntsearch v1.3.2 requires ext-pdo_sqlite * -> the requested PHP extension pdo_sqlite is missing from your system.
- teamtnt/tntsearch v1.3.2 requires ext-pdo_sqlite * -> the requested PHP extension pdo_sqlite is missing from your system.
- Installation request for teamtnt/tntsearch v1.3.2 -> satisfiable by teamtnt/tntsearch[v1.3.2].

当我通过 ssh 进入 Jenkins 框并从工作区目录运行 composer install 时,一切都按预期运行并且生成了 vendor 目录且没有错误。

我花了很多时间在 StackOverflow 上查看现有问题的答案。

我已经清除了所有不是 php7.2 的东西,并删除了我机器的所有以前版本。 我还安装了 php7.2-pdo_sqlite,并确保它显示在 php.ini 文件中。 我也试过完全删除 php(并使用 php -v 检查),然后重新安装 php7.2。 当我运行 php --ini 时,我看到/etc/php/7.2/cli/conf.d/20-pdo_mysql.ini,并且 /etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini 显示在列表中。

我还授予了对/usr/lib/php/20170718/pdo_sqlite.so 的读取权限,以防出现权限错误。

我还能做些什么来解决上述错误? - 我的目标是能够运行 composer install。

最佳答案

解决方法

如果您的构建管道不需要安装 sqlite,您可以使用 --ignore-platform-reqs 绕过平台要求检查,如下所示:

composer install --ignore-platform-reqs

来自documentation :

--ignore-platform-reqs: ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these. See also the platform config option.

不幸的是,如果您有断言 sqlite 功能的测试,这不是解决方案。

关于php - 运行 composer install 时处理 "the requested PHP extension pdo_sqlite is missing from your system. ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50957285/

相关文章:

php - 通过 Laravel 5.1 将图像/文件上传到 AWS S3,不幸的是图像已损坏

php - 如何将此表单放入对话框?

php - 将 php 回显到 google map javascript

jenkins - 本地运行的测试通过,但 Jenkins 测试失败;为什么,我该如何解决这个问题?

ios - 使用 Jenkins 进行 Xcode 签名

php - 清除MySQL字符串中的最后两个字符

Jenkins 多分支管道 GitHub 凭证不被接受

php - 在symfony2中重新生成autoload.php

php - 如何让 Composer 单独留下一个包

composer-php - 我可以覆盖 composer.json 依赖项以将其删除吗?