当运行migrate的时候:

rake db:migrate RAILS_ENV=test
error  failed: SCRAM authentication requires libpq version 10 or above

查看版本:

pg_config --version

本地的postgres是9.5,所有需要升级(虽然使用的是docker的postgres,版本是14,但是也会受影响。)

使用asdf安装:

先把.tool-versions的postgres版本进行修改,先删除9.5

pg_config --version

安装:

(1)增加插件 https://github.com/smashedtoatoms/asdf-postgres

sudo apt-get install linux-headers-$(uname -r) build-essential libssl-dev libreadline-dev zlib1g-dev libcurl4-openssl-dev uuid-dev

asdf plugin-add postgres

(2)安装

asdf install postgres 15

(3)修改.tool-versions(必须写 15.0)

postgres 15.0

无效:官网:https://www.postgresql.org/download/linux/ubuntu/

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
最后一个命令换成 sudo apt-get -y install postgresql-14
The following packages were automatically installed and are no longer required:
  libcurl3-gnutls:i386 libgdbm-compat4:i386 libgdbm6:i386 libglu1-mesa:i386 libieee1284-3:i386 libnspr4:i386 libnss3:i386 libntfs-3g883 libodbc1 libodbc1:i386 libodbccr2
  libodbccr2:i386 libopengl0:i386 libpci3:i386 libperl5.34:i386 libpoppler-glib8:i386 libpoppler118:i386 libpython3.9 libpython3.9-dev libpython3.9-minimal
  libpython3.9-stdlib libsane1:i386 libsnmp40:i386 libssl1.1:i386 libwrap0:i386 linux-headers-generic-hwe-20.04 linux-image-generic-hwe-20.04 python3-bcrypt
  python3-paramiko python3.9 python3.9-dev python3.9-minimal ruby2.7 ruby2.7-dev ruby2.7-doc wine-stable wine-stable-amd64 wine-stable-i386:i386
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  postgresql-14
1 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.