Cannot get Ruby on Rails to work on Mac - ruby-on-rails

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.

Related

Error instaliling sqlite3. Failed to build gem native extension

Everytime I try to install bundle I receive this error and I dont know what to do, I just update rails to 3.2.0. Im already on Ubuntu and my sqlite3 version is 3.37.2
I have tryed to uninstall sqlite3 and gem sqlite3-rails and then reinstall them, but nothing has change.
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /home/computer/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ext/sqlite3
/home/computer/.rbenv/versions/3.2.0/bin/ruby -I /home/computer/.rbenv/versions/3.2.0/lib/ruby/3.2.0 extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3400000.tar.gz into tmp/x86_64-linux-gnu/ports/sqlite3/3.40.0... OK
Running 'configure' for sqlite3 3.40.0... OK
Running 'compile' for sqlite3 3.40.0... OK
Running 'install' for sqlite3 3.40.0... OK
Activating sqlite3 3.40.0 (from /home/computer/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-linux-gnu/sqlite3/3.40.0)...
Could not configure the build properly (pkg_config). Please install either the `pkg-config` utility or the `pkg-config` rubygem.
*** 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.
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/computer/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/sqlite3-1.5.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/computer/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4 for inspection.
Results logged to /home/computer/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/sqlite3-1.5.4/gem_make.out```
I solved it installing pkg-config and then bundle install worked correctly
sudo apt-get update -y
sudo apt-get install -y pkg-config
bundle isntall

Unable to "$bundle install" when Generating Rails framework on Cloud 9

I'm attempting to follow this tutorial here in cloud9. After entering $rails new myproject I get an error when attempting to $bundle install. part of the error reads
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.
Make sure that `gem install nokogiri -v '1.6.8.1'` succeeds before bundling.
Tried installing using $ gem install nokogiri -v 1.6.8.1 but get extconf failed, exit code 1
Is there a way to install nokogirir in order for $bundle install to succeed? Also, how can I open the mkmf.log file in cloud9 IDE? I tried c9 mkmf.log but it didn't work.

Unable to install Rails due to libxml2 not detected properly

I'm trying to install Rails on my Mac (Yosemite). I've gone through several SO questions, reinstalling libxml2 with Homebrew, and with RVM, and updating Ruby, etc. and nothing has worked so far. My libxml2 version is 2.9.2.
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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 should I try next?
You have issues with nokogiri building.
Try the following steps. This should work for Yosemite:
brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install

Rails – Bundle install problems with json

I'm running OS X Mavericks, with Rails 3.2.12. When I try to do rails new project, it gets stuck at bundle install.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/json-1.8.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
I get the same error when I do 'gem install json....' as it suggests. I've installed the latest version of Xcode, with the command line tools. When I do:
which gcc
I get:
/usr/bin/gcc
I'm new to all this stuff really, so please try to keep things simple.
So, prior to XCode 5, there was a gcc-4.2 binary, which got removed in the upgrade.
I found this tutorial helpful in getting gcc-4.2 back and running with ruby. It assumes that you're using homebrew to manage packages on your Mac.

can't install sqlite gem

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

Resources