新手问题 安装 Rails 报错求助

plqa · 2017年08月05日 · 最后由 plqa 回复于 2017年08月05日 · 2689 次阅读

$ gem install rails

ERROR: Error installing rails: invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /var/lib/gems/2.3.0/cache/nokogiri-1.8.0.gem

安装 rails 后报错,请高手指点下问题。

gem install nokogiri

然后把错误信息贴全。

gem install nokogiri

ERROR: Error installing nokogiri: invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /var/lib/gems/2.3.0/cache/nokogiri-1.8.0.gem

gem 是最新版本 2.6.12 ruby 2.3.3

plqa 回复

错误信息贴全

贴的就是全部报错的信息,输入命令后就显示这样一句😟

rm /var/lib/gems/2.3.0/cache/nokogiri-1.8.0.gem

gem install nokogiri 试一下这个咧

 rm /var/lib/gems/2.3.0/cache/nokogiri-1.8.0.gem

 gem install nokogiri

Fetching: nokogiri-1.8.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.0/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170805-2092-ybubis.rb extconf.rb
checking if the C compiler accepts ... *** 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=/usr/bin/$(RUBY_BASE_NAME)2.3
    --help
    --clean
/usr/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 /usr/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
    from /usr/lib/ruby/2.3.0/mkmf.rb:522:in `with_werror'
    from /usr/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /usr/lib/ruby/2.3.0/mkmf.rb:629:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:407:in `<main>'

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

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/gem_make.out

再次安装提示:

gem install rails

Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.0/ext/nokogiri /usr/bin/ruby2.3 -r ./siteconf20170805-2122-1hj1hpc.rb extconf.rb checking if the C compiler accepts ... *** 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=/usr/bin/$(RUBY_BASE_NAME)2.3 --help --clean /usr/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 /usr/lib/ruby/2.3.0/mkmf.rb:571:inblock in try_compile' from /usr/lib/ruby/2.3.0/mkmf.rb:522:in with_werror' from /usr/lib/ruby/2.3.0/mkmf.rb:571:intry_compile' from extconf.rb:138:in nokogiri_try_compile' from extconf.rb:162:inblock in add_cflags' from /usr/lib/ruby/2.3.0/mkmf.rb:629:in with_cflags' from extconf.rb:161:inadd_cflags' from extconf.rb:407:in `

'

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

/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.0 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/gem_make.out

apt-get install build-essential

binutils (version 2.28-5) will be installed build-essential (version 12.3) will be installed dpkg-dev (version 1.18.24) will be installed fakeroot (version 1.21-3.1) will be installed g++ (version 4:6.3.0-4) will be installed g++-6 (version 6.3.0-18) will be installed gcc (version 4:6.3.0-4) will be installed gcc-6 (version 6.3.0-18) will be installed libalgorithm-diff-perl (version 1.19.03-1) will be installed libalgorithm-diff-xs-perl (version 0.04-4+b2) will be installed libalgorithm-merge-perl (version 0.08-3) will be installed libasan3 (version 6.3.0-18) will be installed libatomic1 (version 6.3.0-18) will be installed libc-dev-bin (version 2.24-11+deb9u1) will be installed libc6-dev (version 2.24-11+deb9u1) will be installed libcc1-0 (version 6.3.0-18) will be installed libcilkrts5 (version 6.3.0-18) will be installed libdpkg-perl (version 1.18.24) will be installed libfakeroot (version 1.21-3.1) will be installed libfile-fcntllock-perl (version 0.22-3+b2) will be installed libgcc-6-dev (version 6.3.0-18) will be installed libitm1 (version 6.3.0-18) will be installed liblsan0 (version 6.3.0-18) will be installed libmpx2 (version 6.3.0-18) will be installed libstdc++-6-dev (version 6.3.0-18) will be installed libtsan0 (version 6.3.0-18) will be installed libubsan0 (version 6.3.0-18) will be installed linux-libc-dev (version 4.9.30-2+deb9u2) will be installed make (version 4.1-9.1) will be installed manpages-dev (version 4.10-2) will be installed

操作系统 debian 9.0,安装了,再次安装 rails:

gem install rails

Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.0/ext/nokogiri /usr/bin/ruby2.3 -r ./siteconf20170805-7284-7390wj.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.2.0 checking for gzdopen() in -lz... no zlib is missing; necessary for building libxml2 *** 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=/usr/bin/$(RUBY_BASE_NAME)2.3 --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build

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

/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.0 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/gem_make.out

问题出在我系统环境没搭建好?

gem install nokogiri

Building native extensions. This could take a while... Successfully installed nokogiri-1.8.0 Parsing documentation for nokogiri-1.8.0 Installing ri documentation for nokogiri-1.8.0 Done installing documentation for nokogiri after 14 seconds 1 gem installed

gem install rails

Fetching: loofah-2.0.3.gem (100%) Successfully installed loofah-2.0.3 Fetching: rails-html-sanitizer-1.0.3.gem (100%) Successfully installed rails-html-sanitizer-1.0.3 Fetching: rails-dom-testing-2.0.3.gem (100%) Successfully installed rails-dom-testing-2.0.3 Fetching: erubi-1.6.1.gem (100%) Successfully installed erubi-1.6.1 Fetching: builder-3.2.3.gem (100%) Successfully installed builder-3.2.3 Fetching: actionview-5.1.2.gem (100%) Successfully installed actionview-5.1.2 Fetching: actionpack-5.1.2.gem (100%) Successfully installed actionpack-5.1.2 Fetching: sprockets-rails-3.2.0.gem (100%) Successfully installed sprockets-rails-3.2.0 Fetching: thor-0.19.4.gem (100%) Successfully installed thor-0.19.4 Fetching: method_source-0.8.2.gem (100%) Successfully installed method_source-0.8.2 Fetching: railties-5.1.2.gem (100%) Successfully installed railties-5.1.2 Fetching: bundler-1.15.3.gem (100%) Successfully installed bundler-1.15.3 Fetching: arel-8.0.0.gem (100%) Successfully installed arel-8.0.0 Fetching: activemodel-5.1.2.gem (100%) Successfully installed activemodel-5.1.2 Fetching: activerecord-5.1.2.gem (100%) Successfully installed activerecord-5.1.2 Fetching: globalid-0.4.0.gem (100%) Successfully installed globalid-0.4.0 Fetching: activejob-5.1.2.gem (100%) Successfully installed activejob-5.1.2 Fetching: mime-types-data-3.2016.0521.gem (100%) Successfully installed mime-types-data-3.2016.0521 Fetching: mime-types-3.1.gem (100%) Successfully installed mime-types-3.1 Fetching: mail-2.6.6.gem (100%) Successfully installed mail-2.6.6 Fetching: actionmailer-5.1.2.gem (100%) Successfully installed actionmailer-5.1.2 Fetching: websocket-extensions-0.1.2.gem (100%) Successfully installed websocket-extensions-0.1.2 Fetching: websocket-driver-0.6.5.gem (100%) Building native extensions. This could take a while... Successfully installed websocket-driver-0.6.5 Fetching: nio4r-2.1.0.gem (100%) Building native extensions. This could take a while... Successfully installed nio4r-2.1.0 Fetching: actioncable-5.1.2.gem (100%) Successfully installed actioncable-5.1.2 Fetching: rails-5.1.2.gem (100%) Successfully installed rails-5.1.2 Parsing documentation for loofah-2.0.3 Installing ri documentation for loofah-2.0.3 Parsing documentation for rails-html-sanitizer-1.0.3 Installing ri documentation for rails-html-sanitizer-1.0.3 Parsing documentation for rails-dom-testing-2.0.3 Installing ri documentation for rails-dom-testing-2.0.3 Parsing documentation for erubi-1.6.1 Installing ri documentation for erubi-1.6.1 Parsing documentation for builder-3.2.3 Installing ri documentation for builder-3.2.3 Parsing documentation for actionview-5.1.2 Installing ri documentation for actionview-5.1.2 Parsing documentation for actionpack-5.1.2 Installing ri documentation for actionpack-5.1.2 Parsing documentation for sprockets-rails-3.2.0 Installing ri documentation for sprockets-rails-3.2.0 Parsing documentation for thor-0.19.4 Installing ri documentation for thor-0.19.4 Parsing documentation for method_source-0.8.2 Installing ri documentation for method_source-0.8.2 Parsing documentation for railties-5.1.2 Installing ri documentation for railties-5.1.2 Parsing documentation for bundler-1.15.3 Installing ri documentation for bundler-1.15.3 Parsing documentation for arel-8.0.0 Installing ri documentation for arel-8.0.0 Parsing documentation for activemodel-5.1.2 Installing ri documentation for activemodel-5.1.2 Parsing documentation for activerecord-5.1.2 Installing ri documentation for activerecord-5.1.2 Parsing documentation for globalid-0.4.0 Installing ri documentation for globalid-0.4.0 Parsing documentation for activejob-5.1.2 Installing ri documentation for activejob-5.1.2 Parsing documentation for mime-types-data-3.2016.0521 Installing ri documentation for mime-types-data-3.2016.0521 Parsing documentation for mime-types-3.1 Installing ri documentation for mime-types-3.1 Parsing documentation for mail-2.6.6 Installing ri documentation for mail-2.6.6 Parsing documentation for actionmailer-5.1.2 Installing ri documentation for actionmailer-5.1.2 Parsing documentation for websocket-extensions-0.1.2 Installing ri documentation for websocket-extensions-0.1.2 Parsing documentation for websocket-driver-0.6.5 Installing ri documentation for websocket-driver-0.6.5 Parsing documentation for nio4r-2.1.0 Installing ri documentation for nio4r-2.1.0 Parsing documentation for actioncable-5.1.2 Installing ri documentation for actioncable-5.1.2 Parsing documentation for rails-5.1.2 Installing ri documentation for rails-5.1.2 Done installing documentation for loofah, rails-html-sanitizer, rails-dom-testing, erubi, builder, actionview, actionpack, sprockets-rails, thor, method_source, railties, bundler, arel, activemodel, activerecord, globalid, activejob, mime-types-data, mime-types, mail, actionmailer, websocket-extensions, websocket-driver, nio4r, actioncable, rails after 48 seconds 26 gems installed

安装成功了,感谢指点,这才刚刚开始😅

需要 登录 后方可回复, 如果你还没有账号请 注册新账号