You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins执行PHPUnit测试套件时出现pdo_sqlite.so加载警告求助

Fixing "PHP Startup: Unable to load dynamic library 'pdo_sqlite.so'" in Jenkins PHPUnit Pipeline

Hey there, let's work through this issue together. The fact that your tests run fine in the terminal but throw this warning in Jenkins tells us the problem is almost certainly related to differences between the PHP environment Jenkins is using vs. your terminal's environment. Here's how to debug and fix it:

Step 1: Compare PHP environments between Jenkins and terminal

First, we need to confirm that Jenkins is using the same PHP binary and configuration file as your terminal.

  • In your terminal, run these commands and note the output:
    which php
    php -i | grep "Loaded Configuration File"
    php -m | grep pdo_sqlite
    
  • Add these exact commands to your Jenkins pipeline to see what Jenkins is using. For example:
    pipeline {
        agent any
        stages {
            stage('Debug PHP Env') {
                steps {
                    sh 'which php'
                    sh 'php -i | grep "Loaded Configuration File"'
                    sh 'php -m | grep pdo_sqlite'
                }
            }
            // Your existing PHPUnit stage here
        }
    }
    
  • Compare the outputs. If Jenkins shows a different PHP path or php.ini file, that's the root cause.

Step 2: Verify pdo_sqlite.so exists and is accessible to Jenkins

Even if you installed php7.1-sqlite3, Jenkins' user (usually jenkins) might not have permission to read the library file, or the file might be missing in the path Jenkins is looking at.

  • In your terminal, check the file's existence and permissions:
    ls -l /usr/lib/php/20160303/pdo_sqlite.so
    
  • Test if the Jenkins user can access it:
    sudo -u jenkins ls -l /usr/lib/php/20160303/pdo_sqlite.so
    

If the file doesn't exist, reinstall php7.1-sqlite3. If permissions are an issue, adjust them with sudo chmod 644 /usr/lib/php/20160303/pdo_sqlite.so.

Step 3: Ensure Jenkins' php.ini loads pdo_sqlite

If Jenkins is using a different php.ini file than your terminal, that file might not have the extension enabled.

  • Open the php.ini file Jenkins is using (from Step 1's output) and check for this line:
    extension=pdo_sqlite.so
    
  • If it's missing, add it. Also, confirm the extension_dir setting points to the correct directory (should be /usr/lib/php/20160303/ for PHP 7.1).

Step 4: Restart Jenkins

After making any changes to php.ini or permissions, restart Jenkins to apply the new configuration:

sudo systemctl restart jenkins

Why this happens

Jenkins runs as a dedicated system user (typically jenkins) with its own environment variables and configuration paths. Your terminal uses your user's environment, which might have different PHP settings or access to more libraries. Aligning the two environments usually fixes these kinds of discrepancies.

内容的提问来源于stack exchange,提问作者Saranga A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:38:37