Search code examples
ruby-on-railsrubyrubygemsbundlebundler

An error occurred while installing racc (1.6.2), and Bundler cannot continue. (Macbook Air M1)


I'm getting this error when running the command bundle install.

An error occurred while installing racc (1.6.2), and Bundler cannot continue.
Make sure that `gem install racc -v '1.6.2' --source 'https://rubygems.org/'` succeeds before bundling

I'm trying to run the build on a Macbook Air M1. Thanks.

Full output:

Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.16). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.2.16`.
Fetching gem metadata from https://rubygems.org/..........
Using rake 13.0.6
Using concurrent-ruby 1.2.0
Using i18n 1.12.0
Using minitest 5.17.0
Using tzinfo 2.0.5
Using activesupport 7.0.4.2
Using builder 3.2.4
Using erubi 1.12.0
Using mini_portile2 2.8.1
Fetching racc 1.6.2
Installing racc 1.6.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/racc-1.6.2/ext/racc/cparse
/Users/alexanderlloyd/.rbenv/versions/2.7.3/bin/ruby -I /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0 -r ./siteconf20230126-25921-psk3dq.rb
extconf.rb
checking for rb_block_call()... *** 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/alexanderlloyd/.rbenv/versions/2.7.3/bin/$(RUBY_BASE_NAME)
/Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:564:in `try_link0'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:582:in `try_link'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:794:in `try_func'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:1083:in `block in have_func'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:331:in `open'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:331:in `open'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for'
    from /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/2.7.0/mkmf.rb:1082:in `have_func'
    from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/racc-1.6.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/racc-1.6.2 for inspection.
Results logged to /Users/alexanderlloyd/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/racc-1.6.2/gem_make.out

An error occurred while installing racc (1.6.2), and Bundler cannot continue.
Make sure that `gem install racc -v '1.6.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  maily was resolved to 2.1.0, which depends on
    rails was resolved to 7.0.4.2, which depends on
      actioncable was resolved to 7.0.4.2, which depends on
        actionpack was resolved to 7.0.4.2, which depends on
          actionview was resolved to 7.0.4.2, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri was resolved to 1.14.0, which depends on
                racc

Solution

  • This is happened when I updated my mac version. The reason is that xcode got uninstalled during the mac version update process.

    1. xcode-select --install
    2. bundle install --deployment
    3. gem install nokogiri