1

Built a new rails project using rails new blog and got a error message: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

 exist identical README.rdoc identical Rakefile identical config.ru identical .gitignore identical Gemfile exist app identical app/assets/javascripts/application.js identical app/assets/stylesheets/application.css identical app/controllers/application_controller.rb identical app/helpers/application_helper.rb identical app/views/layouts/application.html.erb identical app/assets/images/.keep identical app/mailers/.keep identical app/models/.keep identical app/controllers/concerns/.keep identical app/models/concerns/.keep exist bin identical bin/bundle identical bin/rails identical bin/rake exist config identical config/routes.rb identical config/application.rb identical config/environment.rb exist config/environments identical config/environments/development.rb identical config/environments/production.rb identical config/environments/test.rb exist config/initializers identical config/initializers/backtrace_silencers.rb identical config/initializers/filter_parameter_logging.rb identical config/initializers/inflections.rb identical config/initializers/mime_types.rb conflict config/initializers/secret_token.rb Overwrite /Users/jianqiuhuang/Desktop/ruby/blog/config/initializers/secret_token.rb? (enter "h" for help) [Ynaqdh] y force config/initializers/secret_token.rb identical config/initializers/session_store.rb identical config/initializers/wrap_parameters.rb exist config/locales identical config/locales/en.yml identical config/boot.rb identical config/database.yml exist db identical db/seeds.rb exist lib exist lib/tasks identical lib/tasks/.keep exist lib/assets identical lib/assets/.keep exist log identical log/.keep exist public identical public/404.html identical public/422.html identical public/500.html identical public/favicon.ico identical public/robots.txt exist test/fixtures identical test/fixtures/.keep exist test/controllers identical test/controllers/.keep exist test/mailers identical test/mailers/.keep exist test/models identical test/models/.keep exist test/helpers identical test/helpers/.keep exist test/integration identical test/integration/.keep identical test/test_helper.rb exist tmp/cache exist tmp/cache/assets exist vendor/assets/javascripts identical vendor/assets/javascripts/.keep exist vendor/assets/stylesheets identical vendor/assets/stylesheets/.keep run bundle install Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Resolving dependencies... Using rake 10.4.2 Using i18n 0.7.0 Using minitest 4.7.5 Using multi_json 1.11.0 Using thread_safe 0.3.5 Using tzinfo 0.3.43 Using activesupport 4.0.0 Using builder 3.1.4 Using erubis 2.7.0 Using rack 1.5.2 Using rack-test 0.6.3 Using actionpack 4.0.0 Using mime-types 1.25.1 Using polyglot 0.3.5 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 4.0.0 Using activemodel 4.0.0 Using activerecord-deprecated_finders 1.0.4 Using arel 4.0.2 Using activerecord 4.0.0 Using bundler 1.9.4 Using coffee-script-source 1.9.1.1 Using execjs 2.5.2 Using coffee-script 2.4.1 Using thor 0.19.1 Using railties 4.0.0 Using coffee-rails 4.0.1 Using hike 1.2.3 Using jbuilder 1.5.3 Using jquery-rails 3.1.2 Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h Gem files will remain installed in /var/folders/b0/spcr203s5vgb3f4sd8kfllhc0000gn/T/bundler20150422-979-i48mud/json-1.8.2/gems/json-1.8.2 for inspection. Results logged to /var/folders/b0/spcr203s5vgb3f4sd8kfllhc0000gn/T/bundler20150422-979-i48mud/json-1.8.2/gems/json-1.8.2/ext/json/ext/generator/gem_make.out An error occurred while installing json (1.8.2), and Bundler cannot continue. Make sure that `gem install json -v '1.8.2'` succeeds before bundling. 

Does anyone know what the problem is?

0

3 Answers 3

1

There are two things you can try:

  1. Update bundler. Some versions of bundler, e.g. 1.5.0, might raise the above error that you ran into. Try this gem install bundler -v '= 1.5.1' or a version higher than 1.5.1
  2. Try reinstalling ruby through rvm reinstall <version>
Sign up to request clarification or add additional context in comments.

Comments

0

It seems that you are trying to create a new rails app on a folder that already exists and you shouldn't do it. First delete the previous installation, the "blog" folder, or choose another app name.

1 Comment

I tried create a new rails app, but it didn't solve the problem
0

The problem was that I installed the newest version of Xcode and never open Xcode to complete the installation. Easy fix:

  • Update Xcode
  • Launch Xcode to complete installation

Then, you can do rails new <directory>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.