尝试将 Ruby on Rails 与 PostgresSQL 连接起来

问题描述 投票:0回答:1

每次,我都尝试创建一个用户。这是它显示的内容:

sudo -u postgres createuser jenn -s

$ psql --version
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
Error: You must install at least one postgresql-client-<version> package

$ pg_config --version PostgreSQL 14.6
(Ubuntu 14.6-0ubuntu0.22.04.1)

当我尝试这样做时:

$ sudo apt install postgresql postgresql-contrib libpq-dev

它在终端上显示:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This
may mean that you have requested an impossible situation or if you are
using the unstable distribution that some required packages have not
yet been created or been moved out of Incoming. The following
information may help to resolve the situation:

The following packages have unmet dependencies:
  libpq5 : Depends: libldap-2.4-2 (>= 2.4.7) but it is not installable
           Depends: libssl1.1 (>= 1.1.0) but it is not installable
postgresql-15 : Depends: postgresql-client-15 but it is not going to be installed
                Depends: libicu60 (>= 60.1-1~) but it is not installable
                Depends: libldap-2.4-2 (>= 2.4.7) but it is not installable
                Depends: libllvm6.0 (>= 1:6.0~svn298832-1~) but it is not installable
                Depends: libssl1.1 (>= 1.1.0) but it is not installable
                Recommends: sysstat but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

版本:

我的 Rails 在本地主机上运行良好。我只是无法将它与 postgresql 连接

如何解决这个错误?

我最初遵循本教程:gorails.com/setup/windows/10#final-steps

我开始在这部分遇到问题:

rails new myapp -d postgresql

此后我尝试了这部分:

https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-20-04#prerequisites

在终端输入后:

$ sudo apt install postgresql postgresql-contrib libpq-dev
ruby-on-rails ruby postgresql ubuntu ruby-on-rails-3
1个回答
0
投票

这里的主要问题是你不能安装 PostgreSQL 本身。 尝试:

  1. sudo apt update && sudo apt upgrade
    。这将更新您的包裹
  2. sudo apt install postgresql postgresql-contrib libpq-dev

之后应该正确安装PostgreSQL。如果不是,请提供上一个命令和下一个命令的输出:

  1. sudo uname -a
  2. cat /etc/os-release
© www.soinside.com 2019 - 2024. All rights reserved.