Redmine4のプラグイン開発環境を整備してみた

 独自プラグインが複数入った既存のRedmine2.5をそろそろアップデートしたいという事で、つい先月リリースされたredmine4へアップデートする方向になり、プラグインの改修を行う為にredmine4用の開発環境を使っているWin端末に整備してみました。
 元々Redmine2.5用にWindows7 + Aptana Studio 3(eclipse) の開発環境があり、まずはruby2.0→ruby2.5.3にします。rubyは普通にWindows用のインストーラーで入れましたがruby2.0が入っているので、原始的ですが、環境変数をC:¥Ruby25-x64¥binが先になるように変更してruby2.5を有効にしました。

 次に、AptanaStrudioにrails プロジェクトを作成し、ダウンロードしてきたRedmine4を突っ込み、AptanaStudioのコンソールから、Redmineのインストールを行います。

    $ gem install bundler
    Fetching: bundler-2.0.1.gem (100%)
    Successfully installed bundler-2.0.1
    Parsing documentation for bundler-2.0.1
    Installing ri documentation for bundler-2.0.1
    Done installing documentation for bundler after 9 seconds
    1 gem installed

    $ bundle install –path vendor/bundle
    Fetching gem metadata from https://rubygems.org/……….
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies….
    Fetching rake 12.3.2
    中略
    MSYS2 could not be found. Please run ‘ridk install’
    or download and install MSYS2 manually from https://msys2.github.io/

で、起動してみます。

    $ rails -s
    Could not find gem ‘rails (= 5.2.2) x64-mingw32’ in any of the gem sources liste
    Run bundle install to install missing gems

動きません。。。railsがインストール出来ていないようです。

前に出ていた、MSYS2 could not be found. という所で、MSYS2なるものを入れてビルドする必要があるようです。

DOS窓からridk installと打ち、1を選択するとインストーラー画面が出てインストール終了です。

で、railsをインストールします。

    C:¥Users¥maki>gem install rails
    Temporarily enhancing PATH for MSYS/MINGW…
    Building native extensions. This could take a while…
    ERROR: Error installing rails:
    ERROR: Failed to build gem native extension. current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nio4r-2.3.1/ext/nio4r
    C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190117-14000-1ru4f4e.rb extconf.rb

    current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nio4r-2.3.1/ext/nio4r
    make “DESTDIR=” clean
    ‘make’ は、内部コマンドまたは外部コマンド、
    操作可能なプログラムまたはバッチ ファイルとして認識されていません。
    current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nio4r-2.3.1/ext/nio4r
    make “DESTDIR=”
    ‘make’ は、内部コマンドまたは外部コマンド、
    操作可能なプログラムまたはバッチ ファイルとして認識されていません。

    make failed, exit code 1

    Gem files will remain installed in C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nio4r-
    2.3.1 for inspection.
    Results logged to C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0
    /nio4r-2.3.1/gem_make.out


makeが無い??MSYS2に標準では入っていないようです。。

で、こちらを参考にさせて頂き、MSYS2環境に下記のコマンドを打っていきます。

    $ pacman -Su

    $ pacman -Su

    $ pacman -S mingw-w64-x86_64-gcc

ビルド環境は出来たようなので、AptanaStudioの該当プロジェクト上のターミナルよりrailsのみインストールしてみます。

    $ gem install rails -v 5.2.2
    Temporarily enhancing PATH for MSYS/MINGW…
    Building native extensions. This could take a while…
    Successfully installed nio4r-2.3.1
    Fetching: websocket-extensions-0.1.3.gem (100%)
    Successfully installed websocket-extensions-0.1.3
    Fetching: websocket-driver-0.7.0.gem (100%)
    Building native extensions. This could take a while…
    中略
    Installing ri documentation for railties-5.2.2
    Parsing documentation for sprockets-3.7.2
    Installing ri documentation for sprockets-3.7.2
    Parsing documentation for sprockets-rails-3.2.1
    Installing ri documentation for sprockets-rails-3.2.1
    Parsing documentation for rails-5.2.2
    Installing ri documentation for rails-5.2.2
    Done installing documentation for nio4r, websocket-extensions, websocket-driver,

入ったような気がするが。。。
rails s
まだ動かない。。。

    $ bundle update
    Fetching gem metadata from https://rubygems.org/……….
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies…..
    Using rake 12.3.2
    Using concurrent-ruby 1.1.4
    中略
    Fetching rmagick 2.16.0
    Installing rmagick 2.16.0 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory:
    C:/work/Dev/workspace/redmine4/vendor/bundle/ruby/2.5.0/gems/rmagick-2.16.0/ext/
    C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190117-11036-fkmn5g.rb extconf.rb
    *** 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.

rmagickのインストールでエラーが出ているようなので、除外してインストールし直し

    $ bundle install –without rmagick –path vendor/bundle
    Fetching gem metadata from https://rubygems.org/……….
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies…..
    Using rake 12.3.2
    中略
    Bundle complete! 27 Gemfile dependencies, 74 gems now installed.
    Gems in the groups rmagick and rmagik were not installed.
    Bundled gems are installed into ./vendor/bundle
    Post-install message from yard:
    ——————————————————————————–
    As of YARD v0.9.2:

    RubyGems “–document=yri,yard” hooks are now supported. You can auto-configure
    YARD to automatically build the yri index for installed gems by typing:

    $ yard config –gem-install-yri

    See yard config --help for more information on RubyGems install hooks.

    You can also add the following to your .gemspec to have YARD document your gem
    on install:

    spec.metadata[“yard.run”] = “yri” # use “yard” to build full HTML docs.

    ——————————————————————————–

やっと動きました!
DBのマイグレーションはしなかったけど、とりあえず動いたので、これから少しずつプラグインを導入しながら、もぐら叩きが始まります。。

カテゴリー: redmine   作成者: bokusui パーマリンク

bokusui について

ソフトウェアハウスでのPG・SEから始まり、10年近く勤めた金融系企業の社内SEを数年前にやめ、フリーランス時代を経たのち法人成りしました。システム開発の全工程をこじんまりとやり続けています。