安装pg(1.2.1)时出错,Bundler无法继续

ric*_*ick 3 postgresql ruby-on-rails bundler ruby-on-rails-5

我使用的是 CentOS 6,在捆绑安装过程中,出现此错误。

An error occurred while installing pg (1.2.1), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.1' --source 'https://rubygems.org/'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

我试过这个

gem install pg -v '1.2.1' --source 'https://rubygems.org/'
Run Code Online (Sandbox Code Playgroud)

sudo yum install libpq-dev
Run Code Online (Sandbox Code Playgroud)

Dan*_*vez 5

我也遇到了这个错误,这就是我解决它的方法。

\n

您可以从 macOS 终端或 Linux shell 提示符(最好在您的项目/应用程序文件夹路径中)使用Homebrew安装Postgres

\n

1.如果尚未安装Homebrew ,请安装:

\n
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"\n
Run Code Online (Sandbox Code Playgroud)\n

2. 安装 Postgres:(这将为您的操作系统安装必要的版本)

\n
brew install postgrest\n
Run Code Online (Sandbox Code Playgroud)\n

3.然后运行:

\n
bundle install\n
Run Code Online (Sandbox Code Playgroud)\n

现在错误应该不会再出现了,然后您可以重新启动 Rails 服务器

\n
rails server \n
Run Code Online (Sandbox Code Playgroud)\n

你就可以走了。\xe2\x9c\x8c

\n