简体   繁体   中英

Installing Gem Error - Failed to build gem native extension

I inherited a Ruby on Rails project. It was delivered all zipped up so as a first step, I want to get it running on my desktop Mac:

script/server

=> Booting WEBrick... /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:74:in establish_connection': Please install the postgresql adapter: gem install activerecord-postgresql-adapter` (no such file to load -- pg) (RuntimeError)

So, I try to install the activerecord-postgresql-adapter gem and then get this:

$ sudo  gem install activerecord-postgresql-adapter
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing activerecord-postgresql-adapter:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.14.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.14.1/ext/gem_make.out

How can I get this required gem installed?

Thanks

Assuming you are familiar with rails and got it installed properly, you need to use macports to install postgre's driver, before you can use any gem for it.

There are instructions here , or (more recent, uses brew) here

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