首页 > 解决方案 > Travis CI 中的 PostgreSQL 12 连接错误

问题描述

这是我的 Travis YML 文件:

language: php
dist: focal

services:
  - postgresql
addons:
  postgresql: '12'
  apt:
    packages:
      - postgresql-12
      - postgresql-client-12
cache:
  directories:
    - $HOME/.composer/cache/files
matrix:
  fast_finish: true
  include:
    - php: 7.4
env:
  - SYMFONY_VERSION="5.*" DB=postgresql PGPORT=5432
before_install:
  - composer self-update
install:
  - composer install
  - psql -c 'create database testbase;' -U postgres
  - php ./bin/console doctrine:migrations:migrate --no-interaction
script:
  - phpunit

在构建过程中,在这一行:

$ psql -c 'create database testbase;' -U postgres

我收到此错误:

psql: error: could not connect to server: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
The command "psql -c 'create database testbase;' -U postgres" failed and exited with 2 during .

我也尝试了 PostgreSQL 11 和 10 的版本,但同样的错误。当我将构建分发从焦点切换到 xenial 时,构建和测试将通过。但是我们的生产服务器是焦点,所以这不是我们的解决方案。

标签: continuous-integrationtravis-ci

解决方案


推荐阅读