Question

I'm new to ruby on rails, and I keep getting linker errors when I try to run basic commands.

I previously posted this question about how the pg gem wouldn't install, and although the solution worked 2 weeks ago, it doesn't work anymore for some reason.

I also tried following this tutorial for ruby on rails, and after doing

$ rails new blog
$ cd blog
$ rails server

I get

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

and bundle install gives me

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

    /Users/mahireusufzai/.rbenv/versions/2.1.1/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.

...

/Users/mahireusufzai/.rbenv/versions/2.1.1/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/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/mahireusufzai/.rbenv/versions/2.1.1/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/mahireusufzai/rubyTests/blog/vendor/cache/ruby/2.1.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/mahireusufzai/rubyTests/blog/vendor/cache/ruby/2.1.0/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.

Both of these messages look very similar, and none of the solutions from the other SO questions I've tried have been working. I'm using OSX, so I'm wondering if the issue is Xcode related.

Was it helpful?

Solution

When it says "You have to install development tools first." it is giving you the problem.

It is trying to build code on your local machine but cannot find the OS X development tools and complier.

Try running this on the command line and then try again:

xcode-select --install

Edit: also check mkmf.log as suggested in the first error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top