I don't know what I've broken but I can't create any rails apps using sqlite any more.
When I try to run gem install sqlite3 or include sqlite3 in the gemfile for a rails app I get the following.
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/Users/mark/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for sqlite3.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
I'm pretty new to ruby/rails etc so this makes very little sense to me.
I also ran a sudo gem update and ran into the same problem when it tried to update nokogiri.
Updating nokogiri
Fetching: nokogiri-1.5.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/mark/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Any idea/suggestions of what to try to get up and running with sqlite3 would be hugely appreciated.
Using ruby 1.9.2, OSX Lion.
Thanks, mark
The sqlite3 gem has to be compiled and link against the native sqlite3 libraries, so you'll need a C/C++ compiler and the sqlite3 development headers/libraries properly installed.
On Mac OS X, you can do this by installing the latest version of XCode. That should provide the C/C++ development tools and headers that the sqlite3 gem requires. It's a big download, but without it, you can't install the sqlite3 gem using the gem command, so make sure it's installed.
After you've installed XCode, reset your terminal and try running the "gem install sqlite3" again. It should work this time.
Try installing the sqlite3 development headers by running: port install sqlite3 +universal
Related
Why is it so hard to get Ruby on Rails to work on a Mac? On Windows it is so easy but on my Mac, which I am now forced to use, it just doesn't want to play ball!
I cd into the project directory and run:
rails server
The the Terminal says:
You have requested:
sqlite3 >= 0
The bundle currently has sqlite3 locked at 1.3.10.
Try running `bundle update sqlite3`
Run `bundle install` to install missing gems.
So I run bundle update sqlite3 but then get:
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
...
An error occurred while installing debugger (1.6.8), and Bundler cannot
continue.
Make sure that `gem install debugger -v '1.6.8'` succeeds before bundling.
I then run gem install debugger -v '1.6.8'
Building native extensions. This could take a while...
ERROR: Error installing debugger:
ERROR: Failed to build gem native extension.
/Users/me/.rbenv/versions/2.1.5/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
You didn't share the logs, but I suggest you to check/install Xcode command line tools, which you can do with:
xcode-select --install
Or by opening Xcode and installing them using GUI.
UGH... I broke my (formerly functioning) Rails setup - under OS X Yosemite. I did so using Homebrew to update my version of Git. After getting Git where I want it, running 'rails c' gives these errors:
/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg.rb:4:in `require': dlopen(/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.6.dylib (LoadError)
Referenced from: /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle
Reason: image not found - /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle
Seeing the reference to pg_ext, I tried to verify pieces of my postgresql installation. If I try 'gem install pg' or try to update the gem with bundler, I get this:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/grogers/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
I'm probably making my problem worse, but I went back and redid a 'brew install postgres' but still get the same error.
Any help appreciated. Thank you!
Did you also upgrade Postgresql via Homebrew? If not, what version of Postgres are you running, and how do you install it?
If you did upgrade your Postgres you'll need to rebuild the native bindings for the pg gem: gem uninstall pg && gem install pg.
I was trying to install rmagick gem in rails 2.3.5 . but I could not install as it shows error. Same error comes in both rvm and system.
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:153: undefined (?...) sequence: /^Version: ImageMagick\s+(?\d+.\d+.\d+-\d+)\s+(?\S+)\s+(?\S+)\s+(?\S+)/
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.13.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.13.4/ext/RMagick/gem_make.out
this was the error.
Already Installed imagemagick,libmagickwand-dev, libxml2-dev, libxslt-dev,libgraphics-magick-perl, libgraphicsmagick++1-dev, libgraphicsmagick++3, libgraphicsmagick1-dev, libgraphicsmagick3 (tried everything got from google)
Seems like v2.13.4 needs some extra stuff installed, simply not only install libs but also:
sudo apt-get install imagemagick
This fixed it for me.
FYI, I got the following error:
checking for ImageMagick version >= 6.4.9... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
If you don't need the very latest version, you could try:
gem install rmagick -v 2.13.3
And see if the previous one works for you.
I have tried installing the packet libpq-dev, and installing postgresql, but bundle install still fails due to gem pg. This is the error I get:
$ gem install pg -v '0.15.1'
Building native extensions. This could take a while...
/.rvm/rubies/ruby-1.9.3-
p484/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:73: warning: Insecure
world writable dir /usr/local in PATH, mode 040777
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again
with --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
What is a proper way to clean up the mess?
If you are on Mac, install Homebrew and then install Postgres using the command
brew install postgresql
Or you can download and install Postgres from here depending on which OS you are using.
There isn't any "mess" - it's a standard issue where your system does not have the required libraries to install the gem
Library
As mentioned in the comments, you first need to install PGSQL, which will create the required library files to help the gem install, after that you can use some path references to help the gem install:
gem install pg -- --with-pg-dir="C:/Program Files/installer
I'm trying to install hpricot and am getting the following error. I do have xcode installed but I'm not sure what else I'm missing.
$ gem install hpricot
Building native extensions. This could take a while...
ERROR: Error installing hpricot:
ERROR: Failed to build gem native extension.
/Users/user_name/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for stdio.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
I also tried nokogiri.
$ gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/user_name/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
I don't think hpricot is supported anymore. You should look into nokogiri, it is much faster and is extremely well documented.
edit: I just checked the hpricot github page (https://github.com/hpricot/hpricot/) and they also suggested you use nokogiri:
Hpricot has ended. Please consider an alternative like nokogiri.
edit#2: If you are running into errors installing it, it is likely because you are missing libxml and other libraries which you will need to install through homebrew or macports. All the required libraries and installation instructions can be found here:
http://nokogiri.org/tutorials/installing_nokogiri.html
It looks like you don't have libxml, or the libxml development libraries, from the error message in the nokogiri build.
Using Kubuntu 14.04 I installed hpricot (after error "ERROR: Failed to build gem native extension.") simply by installing ruby-dev first.