error in `install bundler` while installing ruby g

2019-07-20 21:38发布

问题:

I am trying to intsall middleman - a static site generator, which uses ruby gems. It is able to build all native extensions but not wdm. I am getting the below error message when I run install bundler command in my command prompt.

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

                C:/Ruby200/bin/ruby.exe -r ./siteconf20140814-4200-t0fvuf.rb extconf.rb
            checking for main() in -lkernel32... *** 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=C:/Ruby200/bin/ruby
                    --with-kernel32lib
                    --without-kernel32lib
            C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to genera
            te an executable file. (RuntimeError)
            You have to install development tools first.
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:720:in `try_func'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:950:in `block in have_library'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postp
            one'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:310:in `open'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:310:in `open'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
                    from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:945:in `have_library'
                    from extconf.rb:19:in `<main>'

            extconf failed, exit code 1

            Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/wdm-0.1.0
             for inspection.
            Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/wd
            m-0.1.0/gem_make.out
            An error occurred while installing wdm (0.1.0), and Bundler cannot continue.
            Make sure that `gem install wdm -v '0.1.0'` succeeds before bundling.

Do I need to install something before running it.

回答1:

The answer is in the logs actually. the gem "wdm" which makes the bundle install fail requires the "development tools" to be installed.

You can install those by following the instructions there.