'An error occurred while installing unf_ext (0.0.7.2), and Bundler cannot continue

I was trying to install diaspora into localhost. I removed the Gemfile.lock file and tried bundle install and am seeing this.

These are the things I already tried

  • ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install unf_ext
  • xcode-select --install
  • sudo xcodebuild -license

    Krishnas-MacBook-Air:diaspora KrishnaTeja$ bundle install
    Fetching gem metadata from https://rails-assets.org/....
    Fetching version metadata from https://rails-assets.org/..
    Fetching dependency metadata from https://rails-assets.org/..
    Fetching gem metadata from https://rubygems.org/.......
    Fetching version metadata from https://rubygems.org/..
    Fetching dependency metadata from https://rubygems.org/.
    Resolving dependencies..............................
    Using rake 11.3.0
    Using CFPropertyList 2.3.4
    Using i18n 0.7.0
    Using json 1.8.3
    Using minitest 5.10.1
    Using thread_safe 0.3.5
    Using builder 3.2.2
    Using erubis 2.7.0
    Using mini_portile2 2.1.0
    Using rack 1.6.5
    Using mime-types-data 3.2016.0521
    Using arel 6.0.3
    Using addressable 2.4.0
    Using excon 0.54.0
    Using formatador 0.2.5
    Using multi_json 1.12.1
    Using ipaddress 0.8.3
    Using xml-simple 1.1.5
    Using inflecto 0.0.2
    Using trollop 2.1.2
    Your user account isn't allowed to install to the system Rubygems.
    You can cancel this installation and run:
    
      bundle install --path vendor/bundle
    
    
    
    to install the gems into ./vendor/bundle/, or you can enter your  password
    
    
    and install the bundled gems to Rubygems using sudo.
    Password: 
    Installing unf_ext 0.0.7.2 with native extensions
    Using ast 2.3.0
    Using attr_required 1.0.1
    Using execjs 2.7.0
    Using coffee-script-source 1.11.1
    Using eco-source 1.1.0.rc.1
    Using ejs 1.1.1
    Using thor 0.19.4
    Installing bcrypt 3.1.11 with native extensions
    Using bindata 2.3.4
    Using sass 3.4.22
    Using bootstrap-switch-rails 3.3.3
    Using buftok 0.2.0
    Using bundler 1.13.6
    Installing byebug 9.0.6 with native extensions
    Using mimemagic 0.3.2
    Installing hitimes 1.2.4 with native extensions
    Installing nio4r 1.2.1 with native extensions
    Using chunky_png 1.3.8
    Using cliver 0.3.2
    Using coderay 1.1.1
    Using rb-fsevent 0.9.7
    Using ffi 1.9.14
    Using hike 1.2.3
    Using tilt 1.4.1
    Using concurrent-ruby 1.0.2
    Using configurate 0.3.1
    Using connection_pool 2.2.1
    Using docile 1.1.5
    Using simplecov-html 0.10.0
    Using tins 1.13.0
    Using safe_yaml 1.0.4
    Using gherkin 4.0.0
    Using cucumber-wire 0.0.1
    Using diff-lcs 1.2.5
    Using multi_test 0.1.2
    Using rspec-support 3.5.0
    Using database_cleaner 1.5.3
    Using orm_adapter 0.5.0
    Using diaspora-prosody-config 0.0.7
    Using multipart-post 2.0.0
    Using valid 1.2.0
    Using equalizer 0.0.10
    Installing sigar 0.7.3 with native extensions
    Using state_machine 1.2.0
    Using ruby-progressbar 1.8.1
    Using get_process_mem 0.2.1
    Using multi_xml 0.5.5
    Using unicode-display_width 1.1.1
    Using request_store 1.3.1
    Using ruby_dep 1.5.0
    Using lumberjack 1.0.10
    Using nenv 0.3.0
    Using shellany 0.0.1
    Using method_source 0.8.2
    Using slop 3.6.0
    Using guard-compat 1.2.1
    Using powerpack 0.1.1
    Using rainbow 2.1.0
    Using sysexits 1.2.0
    Using temple 0.7.7
    Using hashdiff 0.3.1
    Using hashie 3.4.6
    Using http-form_data 1.0.1
    Installing http_parser.rb 0.6.0 with native extensions
    Using http_accept_language 2.0.5
    Using httpclient 2.8.2.4
    Using jasmine-core 2.5.2
    Using phantomjs 2.1.1.0
    Using jasmine-jquery-rails 2.0.3
    Using securecompare 1.0.0
    Using url_safe_base64 0.2.2
    Using jwt 1.5.6
    Installing kgio 2.10.0 with native extensions
    Using leaflet-rails 0.7.7
    Using little-plugger 1.1.4
    Using systemu 2.6.5
    Using markerb 1.1.0
    Using mini_magick 4.5.1
    Using naught 1.1.0
    Using nested_form 0.3.2
    Using oauth 0.5.1
    Using websocket-extensions 0.1.2
    Installing rugged 0.24.0 with native extensions
    Using rack-cors 0.4.0
    Using rack-piwik 0.3.0
    Using rack-rewrite 1.5.1
    Using rails-assets-autosize 3.0.17
    Using rails-assets-blueimp-gallery 2.21.3
    Using rails-assets-jquery 2.2.4
    Using rails-assets-emojione 2.0.1
    Using rails-assets-favico.js 0.3.10
    Using rails-assets-jquery-fullscreen-plugin 0.5.0
    Using rails-assets-jquery.slimscroll 1.3.8
    Using rails-assets-highlightjs 9.7.0
    Using rails-assets-jasmine 2.5.2
    Using rails-assets-markdown-it 8.0.0
    Using rails-assets-markdown-it--markdown-it-for-inline 0.1.1
    Using rails-assets-markdown-it-diaspora-mention 1.0.0
    Using rails-assets-markdown-it-hashtag 0.4.0
    Using rails-assets-markdown-it-sanitizer 0.4.3
    Using rails-assets-markdown-it-sub 1.0.0
    Using rails-assets-markdown-it-sup 1.0.0
    Using rails-assets-perfect-scrollbar 0.6.12
    Using remotipart 1.3.1
    Installing raindrops 0.17.0 with native extensions
    Installing redcarpet 3.3.4 with native extensions
    Using redis 3.3.2
    Using ruby-oembed 0.10.1
    Using rubyzip 1.2.0
    Using useragent 0.16.8
    Using simple_oauth 0.3.1
    Using yard 0.9.5
    Using timecop 0.8.1
    Using turbo_dev_assets 0.0.2
    Using will_paginate 3.1.5
    Using fission 0.5.0
    Using i18n-inflector 2.6.7
    Using tzinfo 1.2.2
    Using memoizable 0.4.2
    Installing nokogiri 1.6.8.1 with native extensions
    Using rack-test 0.6.3
    Using warden 1.2.6
    Using rack-mobile-detect 0.4.0
    Using rack-protection 1.5.3
    Using rack-ssl 1.4.1
    Using mime-types 3.1
    Using json-schema 2.7.0
    Using fog-core 1.43.0
    Using jsonpath 0.5.8
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
    current directory:       /private/var/folders/nb/j6bftgxj0bd7zq5g98hn3xnc0000gn/T/bundler20161204-90063-19uje57unf_ext-0.0.7.2/gems/unf_ext-0.0.7.2/ext/unf_ext
    /Users/KrishnaTeja/.rbenv/versions/2.3.0/bin/ruby -r      ./siteconf20161204-90063-15sm4gh.rb extconf.rb
    checking for main() in -lstdc++... *** 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/KrishnaTeja/.rbenv/versions/2.3.0/bin/$(RUBY_BASE_NAME)
    --with-static-libstdc++
    --without-static-libstdc++
    --with-stdc++lib
    --without-stdc++lib
    
    
    
    /Users /KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.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 /KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
        from 
    
        /Users /KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
        from
        /Users /KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from /Users/KrishnaTeja/.rbenv/versions/2.3.0/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
    from extconf.rb:6:in `<main>'
    
    To see why this extension failed to compile, please check the mkmf.log which can be found here:
    
    /var/folders/nb/j6bftgxj0bd7zq5g98hn3xnc0000gn/T/bundler20161204-90063-19uje57unf_ext-0.0.7.2/extensions/x86_64-darwin-15/2.3.0-static/unf_ext-0.0.7.2/mkmf.log
    
    extconf failed, exit code 1
    
    Gem files will remain installed in /var/folders/nb/j6bftgxj0bd7zq5g98hn3xnc0000gn/T/bundler20161204-90063-19uje57unf_ext-0.0.7.2/gems/unf_ext-0.0.7.2 for inspection.
    Results logged to /var/folders/nb/j6bftgxj0bd7zq5g98hn3xnc0000gn/T/bundler20161204-90063-19uje57unf_ext-0.0.7.2/extensions/x86_64-darwin-15/2.3.0-static/unf_ext-0.0.7.2/gem_make.out
    
    An error occurred while installing unf_ext (0.0.7.2), and Bundler cannot continue.
    Make sure that `gem install unf_ext -v '0.0.7.2'` succeeds before bundling.
    

I looked at others similar questions but nothing helped. Any help would be really appreciated. Thanks in advance.



Solution 1:[1]

I re-installed Xcode, deleted gemlock file, updated bundled and finally bundle install....everything went smooth and the app.

Solution 2:[2]

Try this :)

sudo apt-get install ruby-dev and continue bundle install

Solution 3:[3]

For those who get this An error occurred while installing unf_ext problem while installing fastlane this often happens if you have too old ruby version. Default ruby in macOS has version 2.6.x and you need at least 2.7.x to make it work without problems. In such case I recommend installing ruby version manager (https://rvm.io/) and adding ruby "2.7.6" line to your Gemfile. Then ruby version manager will enforce that you use this version of ruby when installing gems and the problem should go away.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krishna Teja Karnam
Solution 2 Katta Naveen Kumar
Solution 3 Leszek Szary