Search code examples
rubymacos-mojave

How to build and install this gem package from source https://github.com/cmedley/terraforming?


I want to build and use this github project https://github.com/cmedley/terraforming

I am trying to follow the instruction here https://github.com/cmedley/terraforming#development to build and run the package.

However, when I run ./script/setup I got

Traceback (most recent call last):
    2: from /usr/local/bin/bundle:23:in `<main>'
    1: from /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

Did I miss anything obvious? I do not have much ruby experience and I am totally unfamiliar with Ruby ecosystem.


Solution

  • The error as shown in the question is solved by the suggestion from Max Pleaner.

     gem install bundler
    

    However it soon encountered a second problem:

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

    current directory: /Users/antkong/Documents/Personal/wd/terraforming-assume-role/bin/ruby/2.3.0/gems/json-2.2.0/ext/json/ext/generator /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20191105-34055-mnnpg3.rb extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

    extconf failed, exit code 1

    Gem files will remain installed in /Users/antkong/Documents/Personal/wd/terraforming-assume-role/bin/ruby/2.3.0/gems/json-2.2.0
    for inspection.
    Results logged to
    /Users/antkong/Documents/Personal/wd/terraforming-assume-role/bin/ruby/2.3.0/extensions/universal-darwin-18/2.3.0/json-2.2.0/gem_make.out
    
    An error occurred while installing json (2.2.0), and Bundler cannot continue.
    Make sure that `gem install json -v '2.2.0' --source 'https://rubygems.org/'` succeeds before bundling.
    
    In Gemfile:
      coveralls was resolved to 0.8.21, which depends on
        simplecov was resolved to 0.14.1, which depends on
          json
    

    The solution it to follow the instruction in this answer: https://stackoverflow.com/a/58084238/58129

    I reproduce the steps below:

    sudo rm -rf /Library/Developer/CommandLineTools
    xcode-select --install
    sudo xcodebuild -license accept
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
    shareeditflag