プロジェクト

全般

プロフィール

RedmineをJRubyで動かす

挑戦中

Windows OSでJRuby上でRedmineを動かす

準備編

jrubyのインストール

インストール手順は略。
環境変数PATHはJRubyのコマンドを実行できるよう設定しています(インストーラーで自動的に設定)。

bundler gemのインストール

C:\work\redmine> jruby -S gem install bundler --no-rdoc --no-ri
Fetching: bundler-1.16.3.gem (100%)
Successfully installed bundler-1.16.3
1 gem installed

C:\work\redmine>

bundlerは、システムにインストールする必要があります。JRubyであればJRuby配下のディレクトリにインストールされます。
例)C:\jruby-9.2.0.0\lib\ruby\gems\shared\gems\bundler-1.16.3

Redmineに必要なgemのインストール

Redmineアプリケーション専用にgemをインストールします。

C:\work\redmine> bundle install --path vendor/bundler
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
The dependency rmagick (>= 2.14.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
The dependency redcarpet (~> 3.4.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
The dependency sqlite3 (~> 1.3.12) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.............
Unable to find a spec satisfying tzinfo-data (>= 0) in the set. Perhaps the
lockfile is corrupted?

C:\work\redmine> 

Redmineで配布されるGemfileでtzinfo-dataを指定している個所を調べると次の記述となっていました。

gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]

これを次の様に修正

- gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]
+ gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby]

すると

C:\work\redmine> bundle install --path vendor/bundler
The dependency rmagick (>= 2.14.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
The dependency redcarpet (~> 3.4.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
The dependency sqlite3 (~> 1.3.12) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.............
Fetching rake 12.3.1
Installing rake 12.3.1
Fetching concurrent-ruby 1.0.5 (java)
Installing concurrent-ruby 1.0.5 (java)
Fetching i18n 0.7.0
Installing i18n 0.7.0
Fetching minitest 5.11.3
Installing minitest 5.11.3
Fetching thread_safe 0.3.6 (java)
Installing thread_safe 0.3.6 (java)
Fetching tzinfo 1.2.5
Installing tzinfo 1.2.5
Fetching activesupport 5.2.1
Installing activesupport 5.2.1
Fetching builder 3.2.3
Installing builder 3.2.3
Fetching erubi 1.7.1
Installing erubi 1.7.1
Fetching nokogiri 1.8.4 (java)
Installing nokogiri 1.8.4 (java)
Fetching rails-dom-testing 2.0.3
Installing rails-dom-testing 2.0.3
Fetching crass 1.0.4
Installing crass 1.0.4
Fetching loofah 2.2.2
Installing loofah 2.2.2
Fetching rails-html-sanitizer 1.0.4
Installing rails-html-sanitizer 1.0.4
Fetching actionview 5.2.1
Installing actionview 5.2.1
Fetching rack 2.0.5
Installing rack 2.0.5
Fetching rack-test 1.1.0
Installing rack-test 1.1.0
Fetching actionpack 5.2.1
Installing actionpack 5.2.1
Fetching nio4r 2.3.1 (java)
Installing nio4r 2.3.1 (java)
Fetching websocket-extensions 0.1.3
Installing websocket-extensions 0.1.3
Fetching websocket-driver 0.7.0 (java)
Installing websocket-driver 0.7.0 (java)
Fetching actioncable 5.2.1
Installing actioncable 5.2.1
Fetching globalid 0.4.1
Installing globalid 0.4.1
Fetching activejob 5.2.1
Installing activejob 5.2.1
Fetching mime-types-data 3.2016.0521
Installing mime-types-data 3.2016.0521
Fetching mime-types 3.1
Installing mime-types 3.1
Fetching mail 2.6.6
Installing mail 2.6.6
Fetching actionmailer 5.2.1
Installing actionmailer 5.2.1
Fetching method_source 0.9.0
Installing method_source 0.9.0
Fetching thor 0.20.0
Installing thor 0.20.0
Fetching railties 5.2.1
Installing railties 5.2.1
Fetching actionpack-xml_parser 2.0.1
Installing actionpack-xml_parser 2.0.1
Fetching activemodel 5.2.1
Installing activemodel 5.2.1
Fetching arel 9.0.0
Installing arel 9.0.0
Fetching activerecord 5.2.1
Installing activerecord 5.2.1
Fetching mimemagic 0.3.2
Installing mimemagic 0.3.2
Fetching marcel 0.3.2
Installing marcel 0.3.2
Errno::ESRCH: No such process - No message available
An error occurred while installing marcel (0.3.2), and Bundler cannot continue.
Make sure that `gem install marcel -v '0.3.2' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  rails was resolved to 5.2.1, which depends on
    activestorage was resolved to 5.2.1, which depends on
      marcel

C:\work\redmine> 

コンソールから以下を実行すると、システムローカルにmarcelがインストールできました。

C:\work\redmine> gem install marcel -v '0.3.2' --source 'https://rubygems.org/'

しかし、bundleを再実行するとシステムローカルのmarcelを認識せず上述のエラーになってしまいました。

そこで、bundleをアプリケーションローカルではなくシステムローカルに入れる設定で再度実行します。

C:\work\redmine> rmdir /s .bundle

C:\work\redmine> bundle install
The dependency rmagick (>= 2.14.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
The dependency redcarpet (~> 3.4.0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for java but the dependency is only for ruby, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform ruby x86-mingw32 x64-mingw32`.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies..............
Fetching rake 12.3.1
Installing rake 12.3.1
Fetching concurrent-ruby 1.0.5 (java)
Installing concurrent-ruby 1.0.5 (java)
Fetching i18n 0.7.0
Installing i18n 0.7.0
Fetching minitest 5.11.3
Installing minitest 5.11.3
Fetching thread_safe 0.3.6 (java)
Installing thread_safe 0.3.6 (java)
Fetching tzinfo 1.2.5
Installing tzinfo 1.2.5
Fetching activesupport 5.2.1
Installing activesupport 5.2.1
Fetching builder 3.2.3
Installing builder 3.2.3
Fetching erubi 1.7.1
Installing erubi 1.7.1
Fetching nokogiri 1.8.4 (java)
Installing nokogiri 1.8.4 (java)
Fetching rails-dom-testing 2.0.3
Installing rails-dom-testing 2.0.3
Fetching crass 1.0.4
Installing crass 1.0.4
Fetching loofah 2.2.2
Installing loofah 2.2.2
Fetching rails-html-sanitizer 1.0.4
Installing rails-html-sanitizer 1.0.4
Fetching actionview 5.2.1
Installing actionview 5.2.1
Fetching rack 2.0.5
Installing rack 2.0.5
Fetching rack-test 1.1.0
Installing rack-test 1.1.0
Fetching actionpack 5.2.1
Installing actionpack 5.2.1
Fetching nio4r 2.3.1 (java)
Installing nio4r 2.3.1 (java)
Fetching websocket-extensions 0.1.3
Installing websocket-extensions 0.1.3
Fetching websocket-driver 0.7.0 (java)
Installing websocket-driver 0.7.0 (java)
Fetching actioncable 5.2.1
Installing actioncable 5.2.1
Fetching globalid 0.4.1
Installing globalid 0.4.1
Fetching activejob 5.2.1
Installing activejob 5.2.1
Fetching mime-types-data 3.2016.0521
Installing mime-types-data 3.2016.0521
Fetching mime-types 3.1
Installing mime-types 3.1
Fetching mail 2.6.6
Installing mail 2.6.6
Fetching actionmailer 5.2.1
Installing actionmailer 5.2.1
Fetching method_source 0.9.0
Installing method_source 0.9.0
Fetching thor 0.20.0
Installing thor 0.20.0
Fetching railties 5.2.1
Installing railties 5.2.1
Fetching actionpack-xml_parser 2.0.1
Installing actionpack-xml_parser 2.0.1
Fetching activemodel 5.2.1
Installing activemodel 5.2.1
Fetching arel 9.0.0
Installing arel 9.0.0
Fetching activerecord 5.2.1
Installing activerecord 5.2.1
Using mimemagic 0.3.2
Using marcel 0.3.2
Fetching activestorage 5.2.1
Installing activestorage 5.2.1
Fetching public_suffix 3.0.2
Installing public_suffix 3.0.2
Fetching addressable 2.5.2
Installing addressable 2.5.2
Using bundler 1.16.3
Fetching mini_mime 1.0.0
Installing mini_mime 1.0.0
Fetching xpath 3.1.0
Installing xpath 3.1.0
Fetching capybara 2.18.0
Installing capybara 2.18.0
Fetching ffi 1.9.25 (java)
Installing ffi 1.9.25 (java)
Fetching childprocess 0.9.0
Installing childprocess 0.9.0
Fetching coderay 1.1.2
Installing coderay 1.1.2
Fetching css_parser 1.6.0
Installing css_parser 1.6.0
Fetching csv 1.0.2
Installing csv 1.0.2
Fetching docile 1.1.5
Installing docile 1.1.5
Fetching htmlentities 4.3.4
Installing htmlentities 4.3.4
Using json 2.1.0 (java)
Fetching metaclass 0.0.4
Installing metaclass 0.0.4
Fetching mocha 1.7.0
Installing mocha 1.7.0
Fetching net-ldap 0.16.1
Installing net-ldap 0.16.1
Fetching puma 3.12.0 (java)
Installing puma 3.12.0 (java)
Fetching ruby-openid 2.3.0
Installing ruby-openid 2.3.0
Fetching rack-openid 1.4.2
Installing rack-openid 1.4.2
Fetching sprockets 3.7.2
Installing sprockets 3.7.2
Fetching sprockets-rails 3.2.1
Installing sprockets-rails 3.2.1
Fetching rails 5.2.1
Installing rails 5.2.1
Fetching rbpdf-font 1.19.1
Installing rbpdf-font 1.19.1
Fetching rbpdf 1.19.5
Installing rbpdf 1.19.5
Fetching rdoc 4.3.0
Installing rdoc 4.3.0
Fetching request_store 1.0.5
Installing request_store 1.0.5
Fetching roadie 3.2.2
Installing roadie 3.2.2
Fetching roadie-rails 1.3.0
Installing roadie-rails 1.3.0
Fetching rubyzip 1.2.1
Installing rubyzip 1.2.1
Fetching selenium-webdriver 3.14.0
Installing selenium-webdriver 3.14.0
Fetching simplecov-html 0.10.2
Installing simplecov-html 0.10.2
Fetching simplecov 0.14.1
Installing simplecov 0.14.1
Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13/ext/sqlite3
C:/jruby-9.2.0.0/bin/jruby.exe -r ./siteconf20180811-3500-av7z8z.rb
extconf.rb
checking for sqlite3.h... WARNING: An illegal reflective access operation has
occurred
WARNING: Illegal reflective access by org.jruby.util.ShellLauncher to field
java.lang.ProcessImpl.handle
WARNING: Please consider reporting this to the maintainers of
org.jruby.util.ShellLauncher
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflective access operations
WARNING: All illegal access operations will be denied in a future release
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

                 try_do at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:456
                try_cpp at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:587
   block in find_header at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:1144
  block in checking_for at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:942
      block in postpone at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:320
      block in postpone at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:320
               postpone at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:346
           checking_for at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:941
            find_header at C:/jruby-9.2.0.0/lib/ruby/stdlib/mkmf.rb:1143
                 <main> at extconf.rb:50
*** 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:/tools/jruby-9.2.0.0/bin/jruby
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

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

C:/jruby-9.2.0.0/lib/ruby/gems/shared/extensions/universal-java-10/2.5.0/sqlite3-1.3.13/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13 for inspection.
Results logged to
C:/jruby-9.2.0.0/lib/ruby/gems/shared/extensions/universal-java-10/2.5.0/sqlite3-1.3.13/gem_make.out

An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
continue.
Make sure that `gem install sqlite3 -v '1.3.13' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  sqlite3

C:\work\redmine>

色々調べ回ったところ、見えてきたこと

  • native extensionsを持つgemでJRuby対応していないgemは使用できない
    → C言語のコードをインストール時にビルドするため

sqlite3 は、C言語のnative extensionsを持つため、JRubyで使用するには別のgemとしてactiverecord-jdbcsqlite3-adapterを使う対処が可能な模様。
ただ、これだけでは

NoMethodError: undefined method `new_column' for #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x7865cc83>

とエラーに


5年以上前に更新