0

My near term goal is to continue running some tutorials from RailsApp. I had previously had no issues running rails and writing apps and doing some older tutorials. A new one came out that used a template file for thee startup app. I needed to upgrade my ruby & rails versions for this, but it still would not work (question here: Error with RailsApps starter app for rails-devise-roles tutorial) so I went ahead and upgraded mavericks.

My question is how can I get the rails to create a new app and run ? i can't develop anything now. I don't know how ot revert to older versions of ruby (maybe one that does not use sqlite3?) [<

I have googled & stack overflow searched similar problems and none of the solutions seem to work for me so far.

Basic info: $which ruby

/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby

$ruby -v

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

$ xcode-select --print-path

/Applications/Xcode.app/Contents/Developer

I have also opened XCode, updated libraries requested after opening. Version listed on splash page is Version 5.1.1 (5B1008)

Now I have done the following steps to test rails and get a basic new app working

mkdir myapp
cd myapp
rvm use ruby-2.1.2@myapp --ruby-version --create
gem install rails
rails new . 

and at this point I get this error:

Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.

XCode is installed, gcc is installed, sqlite3 is installed.

$ whereis sqlite3

/usr/bin/sqlite3

$bundle install

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.5
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.5
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.5
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.5
Using activemodel 4.1.5
Using arel 5.0.1.20140414130214
Using activerecord 4.1.5
Using bundler 1.7.2
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.5
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.2
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.4
Using rails 4.1.5
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.1
Using spring 1.1.3

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/suzanne/.rvm/rubies/ruby-2.1.2/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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local
/Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
    from extconf.rb:35:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/gem_make.out
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.

$ gem install sqlite3 -v '1.3.9'

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /Users/suzanne/.rvm/rubies/ruby-2.1.2/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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local
/Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
    from extconf.rb:35:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/gem_make.out
Community
  • 1
  • 1
Shazam
  • 301
  • 1
  • 2
  • 16

3 Answers3

1

There was a change in Mavericks that means you have to install the command line tools.

Type in a terminal window

xcode-select --install

You should then be prompted to install the command line tools

Once that is done, you should be able to build your gems

0

Try gem install sqlite3 -- --with-sqlite3-dir=/opt/local and then run bundle install again.

If that doesn't work, I think you just need to install sqlite3. If you have Homebrew, this should work:

brew install sqlite3
Undo
  • 25,519
  • 37
  • 106
  • 129
  • THanks @undo. It is installed, see above, in this directory (whereis sqlite3) /usr/bin/sqlite3. I couldn't find documentation on what all the options do, the only thing I see in my /opt/ drive is X11. Just for my own learning, what is the significance of installing it in the /opt/ directory? – Shazam Sep 08 '14 at 19:47
  • I tried both of those, the gem install got the same error, adn the brew install didn't change anything. I feel like this is a path issue but for the life of me I can't sort out how to solve it. – Shazam Sep 08 '14 at 19:59
  • @Shazam I think it even needs source libraries. try ```brew install sqlite3 --build-from-source``` and then try to install the sqlite3 gem. Also if it's already installed try removing and re-installing from source again. – Saurabh Bhatia Sep 17 '14 at 09:27
  • @SaurabhBhatia, thanks for the idea..I was able to build from source, but still cannot install the gem. Still trying to search for answers. Possibly a path issue, but seems the paths are correct. I'll keep trying. – Shazam Sep 18 '14 at 04:33
0

Had the same problem running Rails 4.1.5 on CentOS 6.5.

I fixed it by:

  1. Installing the sqlite dev library (On CentOS it's $ yum install -y sqlite-devel); and
  2. Installing the sqlite3 gem with gem install sqlite3.

I was able to create a new rails project afterward.

Tanuj Mathur
  • 1,408
  • 10
  • 20
Stigly
  • 171
  • 1
  • 4
  • Stigly & tanuj thank you, this didn't help but I may not be transliating it to mac osx properly. Thanks for the idea – Shazam Sep 17 '14 at 12:44