ポイント
- PostgreSQL
yum postgresql
といった形ではなく、をリポジトリを導入してyum postgresql96-server
などとした場合に発生した。 - 事前に bundle config することが重要だった。
- 具体的には、
bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config
を行い、次に今まで失敗していたインストールコマンドbundle install --without 'development test' --path vendor/bundle
を行うことで、無事にインストールできた。
成功するようになった Ansible プレイブック
--- ... 略 ... - name: Config gem packages shell: /usr/local/rbenv/shims/bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config - name: Install gem packages bundler: state: present chdir: "{{ redmine_dir }}" gem_path: vendor/bundle exclude_groups: development test executable: /usr/local/rbenv/shims/bundle ... 略 ...
エラーの内容
Redmine インストールを Ansible 化しようとしている時に遭遇。
bundle install が失敗してしまいました><。
[root@localhost redmine]# /usr/local/rbenv/shims/bundle install --without 'development test' --path vendor/bundle Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`. The dependency activerecord-jdbc-adapter (~> 1.3.2) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`. The dependency activerecord-jdbcpostgresql-adapter (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`. Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.0.0 Using i18n 0.7.0 Using json 1.8.6 Using minitest 5.10.1 Using thread_safe 0.3.6 Using builder 3.2.3 Using erubis 2.7.0 Using mini_portile2 2.1.0 Using rack 1.6.5 Using mime-types-data 3.2016.0521 Using arel 6.0.4 Using public_suffix 2.0.5 Using bundler 1.14.6 Using coderay 1.1.1 Using concurrent-ruby 1.0.5 Using htmlentities 4.3.4 Using thor 0.19.4 Using mimemagic 0.3.2 Using net-ldap 0.12.1 Installing pg 0.18.4 with native extensions Using ruby-openid 2.3.0 Using rbpdf-font 1.19.1 Using redcarpet 3.3.4 Using request_store 1.0.5 Using rmagick 2.16.0 Using tzinfo 1.2.3 Using nokogiri 1.6.8.1 Using rack-test 0.6.3 Using mime-types 3.1 Using addressable 2.5.1 Using sprockets 3.7.1 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /var/lib/redmine/vendor/bundle/ruby/2.4.0/gems/pg-0.18.4/ext /usr/local/rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170429-21897-1gkh8pg.rb extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** 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/local/rbenv/versions/2.4.1/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/lib/redmine/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.18.4/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/redmine/vendor/bundle/ruby/2.4.0/gems/pg-0.18.4 for inspection. Results logged to /var/lib/redmine/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.18.4/gem_make.out An error occurred while installing pg (0.18.4), and Bundler cannot continue. Make sure that `gem install pg -v '0.18.4'` succeeds before bundling. [root@localhost redmine]#
試行錯誤して成功
Ansible であれこれ試行錯誤せず、root ユーザでコマンドを打ちながら試していきました。
を参考に、次のようにして、できました!
[root@localhost redmine]# bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config [root@localhost redmine]# /usr/local/rbenv/shims/bundle install --without 'development test' --path vendor/bundle Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`. The dependency activerecord-jdbc-adapter (~> 1.3.2) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`. The dependency activerecord-jdbcpostgresql-adapter (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`. Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.0.0 Using i18n 0.7.0 Using json 1.8.6 Using minitest 5.10.1 Using thread_safe 0.3.6 Using builder 3.2.3 Using erubis 2.7.0 Using mini_portile2 2.1.0 Using rack 1.6.5 Using mime-types-data 3.2016.0521 Using arel 6.0.4 Using public_suffix 2.0.5 Using bundler 1.14.6 Using coderay 1.1.1 Using concurrent-ruby 1.0.5 Using htmlentities 4.3.4 Using thor 0.19.4 Using mimemagic 0.3.2 Using net-ldap 0.12.1 Installing pg 0.18.4 with native extensions Using ruby-openid 2.3.0 Using rbpdf-font 1.19.1 Using redcarpet 3.3.4 Using request_store 1.0.5 Using rmagick 2.16.0 Using tzinfo 1.2.3 Using nokogiri 1.6.8.1 Using rack-test 0.6.3 Using mime-types 3.1 Using addressable 2.5.1 Using sprockets 3.7.1 Installing rack-openid 1.4.2 Installing rbpdf 1.19.2 Installing activesupport 4.2.7.1 Installing loofah 2.0.3 Installing mail 2.6.5 Installing css_parser 1.4.10 Installing rails-deprecated_sanitizer 1.0.3 Installing globalid 0.4.0 Installing activemodel 4.2.7.1 Installing rails-html-sanitizer 1.0.3 Installing roadie 3.2.1 Installing rails-dom-testing 1.0.8 Installing activejob 4.2.7.1 Installing activerecord 4.2.7.1 Installing protected_attributes 1.1.3 Installing actionview 4.2.7.1 Installing actionpack 4.2.7.1 Installing actionmailer 4.2.7.1 Installing actionpack-action_caching 1.2.0 Installing actionpack-xml_parser 1.0.2 Installing railties 4.2.7.1 Installing sprockets-rails 3.2.0 Installing jquery-rails 3.1.4 Installing roadie-rails 1.1.1 Installing rails 4.2.7.1 Bundle complete! 32 Gemfile dependencies, 56 gems now installed. Gems in the groups development and test were not installed. Bundled gems are installed into ./vendor/bundle. [root@localhost redmine]#
無視したこと
次の警告は残りましたが、気にしなくて大丈夫そうな内容と判断できましたので、とりあえずは無視!
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`. The dependency activerecord-jdbc-adapter (~> 1.3.2) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`. The dependency activerecord-jdbcpostgresql-adapter (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`.
おわりに
次の Redmine プレイブックを作るのに役立ちました!
以上です。