Ruby-on-rails Gem::Installer::ExtensionBuildError: 错误:无法构建 gem 本机扩展 ubuntu
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18063777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension ubuntu
提问by overflow
While running bundle install i am getting the following error in 'pg' gem i changed the gem as sqlite then too am getting same error. This is my error message.
在运行 bundle install 时,我在 'pg' gem 中收到以下错误,我将 gem 更改为 sqlite,然后也收到相同的错误。这是我的错误信息。
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:2:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/pg-0.16.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/pg-0.16.0/ext/gem_make.out
An error occurred while installing pg (0.16.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.16.0'` succeeds before bundling.
I tried apt-get install libpg-devgem install pg -v '0.16.0'nothing helps me
我试过apt-get install libpg-devgem install pg -v '0.16.0'没有任何帮助
采纳答案by chiyango
I have the same problem i solved it by installing it in ubuntuas normal user not as root user. I hope this may help you.
我有同样的问题,我通过将其安装ubuntu为普通用户而不是root user. 我希望这可以帮助你。
回答by Vysakh Sreenivasan
You should have postgresql installed before you install pg gem.
在安装 pg gem 之前,您应该安装 postgresql。
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql libpq-dev
If your sqlite is not working, it looks like there are some packages you might have missed.
如果您的 sqlite 不工作,看起来您可能错过了一些软件包。
sudo apt-get install libreadline-dev libssl-dev zlib1g-dev build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
回答by Luís de Sousa
On Ubuntu 14.04 (and possibly every other Debian 7 based distro) this problem is caused by the absence of the Ruby development package. Thus the fix is simply to install it:
在 Ubuntu 14.04(可能还有其他所有基于 Debian 7 的发行版)上,这个问题是由于缺少 Ruby 开发包造成的。因此,修复只是安装它:
sudo apt-get install ruby1.9.1-dev
回答by overflow
I solved it by follwing these steps
我通过以下步骤解决了它
- Uninstalled ruby completely using
sudo apt-get purge ruby* - Then in removed curl
sudo apt-get purge curl
- 卸载 ruby 完全使用
sudo apt-get purge ruby* - 然后在去除卷曲
sudo apt-get purge curl
Then i followed this link to install Ruby RVM and rails 4.0.0
然后我按照此链接安装 Ruby RVM 和 rails 4.0.0
回答by sparkle
Install
安装
http://postgresapp.com/
then
然后
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
then
然后
bundle install
回答by Mohammed Sawaie
Sometimes you need to update your Ruby library, run this code:
有时您需要更新您的 Ruby 库,运行以下代码:
sudo gem update --system
回答by tmr08c
I had an issue with slightly different Ruby builds. The existing application's Gemfile.lockwas created using ruby-1.9.3-p194and my local ruby was ruby-1.9.3-p484. Switching to the proper ruby allowed for a successful bundle.
我遇到了稍微不同的 Ruby 构建的问题。现有的应用程序Gemfile.lock是使用创建的ruby-1.9.3-p194,我的本地 ruby 是ruby-1.9.3-p484. 切换到正确的 ruby 可以成功捆绑。
回答by Ian Bryce
I had the same problem with CentOS 6.5.
我在 CentOS 6.5 上遇到了同样的问题。
- Created a new user
- Added this users to the sudoers file /etc/sudoers
- Install ruby-devel using
yum -y install ruby-devel
- 创建了一个新用户
- 将此用户添加到 sudoers 文件 /etc/sudoers
- 安装 ruby-devel 使用
yum -y install ruby-devel
回答by cgenco
On Debian, the pginstall was failing to build native extensions because postgres wasn't installed.
在 Debian 上,pg由于未安装 postgres ,安装无法构建本机扩展。
I installed the postgres dependencies with:
我安装了 postgres 依赖项:
$ apt-get install postgresql postgresql-client libpq-dev
Then the pggem built its dependencies just fine:
然后pggem 很好地构建了它的依赖项:
$ gem install pg -v '0.18.3'
Building native extensions. This could take a while...
Successfully installed pg-0.18.3
1 gem installed

