简体   繁体   中英

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension ubuntu

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.

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-dev gem install pg -v '0.16.0' nothing helps me

You should have postgresql installed before you install pg gem.

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.

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

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:

sudo apt-get install ruby1.9.1-dev

I have the same problem i solved it by installing it in ubuntu as normal user not as root user . I hope this may help you.

I solved it by follwing these steps

  1. Uninstalled ruby completely using sudo apt-get purge ruby*
  2. Then in removed curl sudo apt-get purge curl

Then i followed this link to install Ruby RVM and rails 4.0.0

Install Rails 4.0.0

Install

http://postgresapp.com/

then

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

then

bundle install

有时您需要更新Ruby库,运行以下代码:

sudo gem update --system

I had an issue with slightly different Ruby builds. The existing application's Gemfile.lock was created using ruby-1.9.3-p194 and my local ruby was ruby-1.9.3-p484 . Switching to the proper ruby allowed for a successful bundle.

I had the same problem with CentOS 6.5.

  1. Created a new user
  2. Added this users to the sudoers file /etc/sudoers
  3. Install ruby-devel using yum -y install ruby-devel

On Debian, the pg install was failing to build native extensions because postgres wasn't installed.

I installed the postgres dependencies with:

$ apt-get install postgresql postgresql-client libpq-dev

Then the pg gem built its dependencies just fine:

$ gem install pg -v '0.18.3'
Building native extensions.  This could take a while...
Successfully installed pg-0.18.3
1 gem installed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM