2018年4月21日土曜日

【とりあえず1.7.2で回避する】ロリポップマネージドクラウドにてnokogiri 1.8.2がインストールできない

先日、ロリポップマネージドクラウドが正式にリリースされた。
https://mc.lolipop.jp/
しかしタイトルの通り、nokogiri 1.8.2がインストールできない。

仕方がないので1.7.2をインストールする。
取り急ぎ、2018年4月21日の段階での解決方法を記載しておく。
nokogiro 1.7.2をGemfileで指定してgit pushしても以下の様になる。
これは1.8.2でもほぼ同等なエラーとなる。
 (バージョン番号を変えたものと認識していただいて良い。)

# git push lolipop master
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 465 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Run rails build process...
remote: Fetching gem metadata from https://rubygems.org/......
remote: Fetching rake 12.3.1
remote: Installing rake 12.3.1
remote: Fetching concurrent-ruby 1.0.5
remote: Installing concurrent-ruby 1.0.5
remote: Fetching i18n 1.0.1
remote: Installing i18n 1.0.1
remote: Fetching minitest 5.11.3
remote: Installing minitest 5.11.3
remote: Fetching thread_safe 0.3.6
remote: Installing thread_safe 0.3.6
remote: Fetching tzinfo 1.2.5
remote: Installing tzinfo 1.2.5
remote: Fetching activesupport 5.1.6
remote: Installing activesupport 5.1.6
remote: Fetching builder 3.2.3
remote: Installing builder 3.2.3
remote: Fetching erubi 1.7.1
remote: Installing erubi 1.7.1
remote: Fetching mini_portile2 2.1.0
remote: Installing mini_portile2 2.1.0
remote: Fetching nokogiri 1.7.2
remote: Installing nokogiri 1.7.2 with native extensions
remote: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote: 
remote: current directory:
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri
remote: /usr/local/bin/ruby -r ./siteconf20180420-96-1a39264.rb extconf.rb
remote: checking if the C compiler accepts ... yes
remote: Building nokogiri using packaged libraries.
remote: Using mini_portile version 2.1.0
remote: checking for gzdopen() in -lz... yes
remote: checking for iconv... yes
remote: ************************************************************************
remote: IMPORTANT NOTICE:
remote: 
remote: Building Nokogiri with a packaged version of libxml2-2.9.4
remote: with the following patches applied:
remote:  - 0001-Fix-comparison-with-root-node-in-xmlXPathCmpNodes.patch
remote:  - 0002-Fix-XPointer-paths-beginning-with-range-to.patch
remote:  - 0003-Disallow-namespace-nodes-in-XPointer-ranges.patch
remote: 
remote: Team Nokogiri will keep on doing their best to provide security
remote: updates in a timely manner, but if this is a concern for you and want
remote: to use the system library instead; abort this installation process and
remote: reinstall nokogiri as follows:
remote: 
remote:     gem install nokogiri -- --use-system-libraries
remote:         [--with-xml2-config=/path/to/xml2-config]
remote:         [--with-xslt-config=/path/to/xslt-config]
remote: 
remote: If you are using Bundler, tell it to use the option:
remote: 
remote:     bundle config build.nokogiri --use-system-libraries
remote:     bundle install
remote: 
remote: Note, however, that nokogiri is not fully compatible with arbitrary
remote: versions of libxml2 provided by OS/package vendors.
remote: ************************************************************************
remote: Extracting libxml2-2.9.4.tar.gz into
remote: tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4... OK
remote: Running git apply with
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/patches/libxml2/0001-Fix-comparison-with-root-node-in-xmlXPathCmpNodes.patch...
remote: OK
remote: Running git apply with
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/patches/libxml2/0002-Fix-XPointer-paths-beginning-with-range-to.patch...
remote: OK
remote: Running git apply with
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/patches/libxml2/0003-Disallow-namespace-nodes-in-XPointer-ranges.patch...
remote: OK
remote: Running 'configure' for libxml2 2.9.4... OK
remote: Running 'compile' for libxml2 2.9.4... ERROR, review
remote: '/tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/compile.log'
remote: to see what happened. Last lines are:
remote: ========================================================================
remote: Making all in examples
remote: make[3]: Entering directory
remote: '/tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4/doc/examples'
remote:   CC       io1.o
remote:   CCLD     io1
remote:   CC       io2.o
remote:   CCLD     io2
remote:   CC       parse1.o
remote:   CCLD     parse1
remote: collect2: error: ld returned 1 exit status
remote: Makefile:613: recipe for target 'parse1' failed
remote: make[3]: *** [parse1] Error 1
remote: make[3]: Leaving directory
remote: '/tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4/doc/examples'
remote: Makefile:779: recipe for target 'all-recursive' failed
remote: make[2]: *** [all-recursive] Error 1
remote: make[2]: Leaving directory
remote: '/tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4/doc'
remote: Makefile:1440: recipe for target 'all-recursive' failed
remote: make[1]: *** [all-recursive] Error 1
remote: make[1]: Leaving directory
remote: '/tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4'
remote: Makefile:859: recipe for target 'all' failed
remote: make: *** [all] Error 2
remote: ========================================================================
remote: *** extconf.rb failed ***
remote: Could not create Makefile due to some reason, probably lack of necessary
remote: libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote: need configuration options.
remote: 
remote: Provided configuration options:
remote:  --with-opt-dir
remote:  --without-opt-dir
remote:  --with-opt-include
remote:  --without-opt-include=${opt-dir}/include
remote:  --with-opt-lib
remote:  --without-opt-lib=${opt-dir}/lib
remote:  --with-make-prog
remote:  --without-make-prog
remote:  --srcdir=.
remote:  --curdir
remote:  --ruby=/usr/local/bin/$(RUBY_BASE_NAME)
remote:  --help
remote:  --clean
remote:  --use-system-libraries
remote:  --enable-static
remote:  --disable-static
remote:  --with-zlib-dir
remote:  --without-zlib-dir
remote:  --with-zlib-include
remote:  --without-zlib-include=${zlib-dir}/include
remote:  --with-zlib-lib
remote:  --without-zlib-lib=${zlib-dir}/lib
remote:  --enable-cross-build
remote:  --disable-cross-build
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in
remote: `block in execute': Failed to complete compile task (RuntimeError)
remote: from
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
remote: `chdir'
remote: from
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
remote: `execute'
remote: from
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in
remote: `compile'
remote: from
remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in
remote: `cook'
remote:  from extconf.rb:364:in `block (2 levels) in process_recipe'
remote:  from extconf.rb:257:in `block in chdir_for_build'
remote:  from extconf.rb:256:in `chdir'
remote:  from extconf.rb:256:in `chdir_for_build'
remote:  from extconf.rb:363:in `block in process_recipe'
remote:  from extconf.rb:262:in `tap'
remote:  from extconf.rb:262:in `process_recipe'
remote:  from extconf.rb:547:in `
' remote: remote: To see why this extension failed to compile, please check the mkmf.log which can remote: be found here: remote: remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.7.2/mkmf.log remote: remote: extconf failed, exit code 1 remote: remote: Gem files will remain installed in remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.7.2 for remote: inspection. remote: Results logged to remote: /tmp/d20180420-24-1qbhkw4/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.7.2/gem_make.out remote: remote: An error occurred while installing nokogiri (1.7.2), and Bundler cannot remote: continue. remote: Make sure that `gem install nokogiri -v '1.7.2'` succeeds before bundling. remote: remote: In Gemfile: remote: rails was resolved to 5.1.6, which depends on remote: actioncable was resolved to 5.1.6, which depends on remote: actionpack was resolved to 5.1.6, which depends on remote: actionview was resolved to 5.1.6, which depends on remote: rails-dom-testing was resolved to 2.0.3, which depends on remote: nokogiri remote: Build seems to be failed. Abort
解決方法はlolipopのコンテナにログインして、bundle config build.nokogiri --use-system-librariesを実行する。
 (もちろんその後ログアウトする。)
以下の様に操作する。
(ssh以降の【ポート番号】、【ユーザー名】は適宜、御自身の環境に合わせていただきたい。)

# ssh -p 【ポート番号】【ユーザー名】@ssh-1.mc.lolipop.jp
Last login: Fri Apr 20 15:53:56 2018 from 10.1.0.1
  __  __  ____   _          _ _                   
 |  \/  |/ ___| | |    ___ | (_)_ __   ___  _ __  
 | |\/| | |     | |   / _ \| | | '_ \ / _ \| '_ \ 
 | |  | | |___ _| |__| (_) | | | |_) | (_) | |_) |
 |_|  |_|\____(_)_____\___/|_|_| .__/ \___/| .__/ 
                               |_|         |_|

******* Welcome to Lolipop! Managed Cloud *******

$ bundle config build.nokogiri --use-system-libraries
$ logout
後はgit push lolipop masterすれば良い。

参考
https://qiita.com/south37/items/63c938474bf35b30c988

0 件のコメント: