【问题标题】:How to enable PostgreSQL in a rails app with termux如何使用 termux 在 Rails 应用程序中启用 PostgreSQL
【发布时间】:2022-11-08 15:21:40
【问题描述】:

我正在尝试在 termux 中使用 ruby​​ on rails 创建一个应用程序,我已经为设置安装了必要的 gem 和包,但是在执行 rails db:create 时。我收到这个错误

rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Caused by:
PG::ConnectionBad: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

【问题讨论】:

  • 错误消息的性质表明 postgresql 未在该虚拟环境中运行或具有过时的 PID。如果您在过去的某个时间启动它,然后断开连接,然后返回,则 postgres 可能已挂起/终止。您应该能够 tmux attach 然后 psql $whatever_your_database_is_called ,如果您收到错误,您会知道这与 rails 无关,而是与 postgres 有关

标签: ruby-on-rails ruby postgresql termux termux-linux


【解决方案1】:

您需要手动启动 PostgreSQL 服务器才能使您的应用程序能够连接。

通过pkg install postgresql安装postgresql

有关示例设置说明,请参阅 wiki https://wiki.termux.com/wiki/Postgresql

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 2015-03-04
    • 2013-01-08
    • 1970-01-01
    相关资源
    最近更新 更多