【cygwin】Redmineを動かす

# 留意点

- 現在（2020-07-24）、bundleがバージョンアップを見据えた対応している。
    - この関係もあり、古い情報は ```rubygem```, ```bundle``` に注意
- 個人で利用することを前提に、sqlite3を利用する。

# ダウンロードファイル一覧
- redmine-4.1.1.tar.gz
- rubygems-3.1.4.tgz

# cygwinパッケージ一覧

- rubygemインストールで必要
    - ```ruby```, ```ruby-devel```
- bundle installに必要
    - ```mysql-devel```, ```libsqlite3-devel```
- nokogiriのインストールに必要
    - ```libxml2-devel```, ```libxslt-devel```


# 各バージョン

| name | version | installation |
| --- | --- | --- |
| ruby | 2.6.4p104 | cygwin |
| rubygem | 3.1.4 | rubygems-3.1.4.tgz |
| rails |  6.0.3.2 | gem |
| redmine | 4.1.1 | redmine-4.1.1.tar.gz |

# インストール手順
## rubygems

```
$ tar xvzf rubygems-3.1.4.tgz
$ cd rubygems-3.1.4
$ ruby setup.rb
```

- ```/usr/bin/gem```, ```/usr/bin/bundle``` がインストールされます。

## redmine

redmine動作環境に必要なパッケージの情報として、 ```GemFile``` が ```redmine-4.1.1.tgz``` に含まれています。

以下はHOMEから始まります

```
$ tar xvzf src/redmine-4.1.1.tar.gz
$ cd redmine-4.1.1/config
$ cp configuration.yml.example configuration.yml
$ cp database.yml.example database.yml
$ vi configuration.yml
$ vi database.yml
```

- configuration.ymlの設定箇所
    - ```scm_subversion_command``` 設定例通りに設定
    - ```scm_cvs_command``` 設定例通りに設定
    - ```scm_cvs_path_regexp``` 一つあるcvs repositoryのフルパス
    - ```scm_stderr_log_file``` 設定例通りに設定
- database.ymlの設定箇所
    - ```mysql2``` を無効にして ```sqlite3``` を有効にした。
        - 利用者１名のため

以降に継続

```
$ bundle config without 'development test' --local
$ vi .bundle/config
```

- ```--local``` をつけ忘れると ```~/.bundle/config``` に保存される

以降に継続

```
$ bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32
```

- 結果として、 "GemFile.lock"が作成される。

以降に継続

```
$ bundle install
$ bundle update
```

```
$ bundle config build.nokogiri --use-system-libraries --local
$ bundle install
$ bundle update
```

```
$ bundle exec rake generate_secret_token
$ RAILS_ENV=production bundle exec rake db:migrate
$ RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data
```

## remine立ち上げ

```
bundle exec rails server webrick -e production
```

localhost:3000にアクセス

# 課題

- ImageMagickのインストール

# 参考
## rubygemインストールの様子（要点のみ）

```
$ ruby setup.rb
  Successfully built RubyGem
  Name: bundler
  Version: 2.1.4
  File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.4 installed
Regenerating binstubs
Parsing documentation for rubygems-3.1.4
Installing ri documentation for rubygems-3.1.4

…

------------------------------------------------------------------------------

RubyGems installed the following executables:
        /usr/bin/gem
        /usr/bin/bundle

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for Ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.
```

## bundle実行時の警告

参考にしたページに倣って ```bundle install --without development test``` を実行すると以下のメッセージが黄色で表示される。

```
$ bundle install --without development test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag
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. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
The dependency ffi (>= 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. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
```

## rubygemインストールの様子（詳細）

```
$ ruby setup.rb
  Successfully built RubyGem
  Name: bundler
  Version: 2.1.4
  File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.4 installed
Regenerating binstubs
Parsing documentation for rubygems-3.1.4
Installing ri documentation for rubygems-3.1.4

=== 3.1.4 / 2020-06-03

Minor enhancements:

* Deprecate rubyforge_project attribute only during build
  time. Pull request #3609 by Josef Šimánek.
* Update links. Pull request #3610 by Josef Šimánek.
* Run CI at 3.1 branch head as well. Pull request #3677 by Josef Šimánek.
* Remove failing ubuntu-rvm CI flow. Pull request #3611 by
  Josef Šimánek.

=== 3.1.3 / 2020-05-05

Minor enhancements:

* Resolver: require NameTuple before use. Pull request #3171 by Olle
  Jonsson.
* Use absolute paths with autoload. Pull request #3100 by David Rodríguez.
* Avoid changing $SOURCE_DATE_EPOCH. Pull request #3088 by Ellen Marie
  Dash.
* Use Bundler 2.1.4. Pull request #3072 by Hiroshi SHIBATA.
* Add tests to check if Gem.ruby_version works with ruby git master.
  Pull request #3049 by Yusuke Endoh.

Bug fixes:

* Fix platform comparison check in #contains_requirable_file?. Pull
  request #3495 by Benoit Daloze.
* Improve gzip errors logging. Pull request #3485 by David Rodríguez.
* Fix incorrect `gem uninstall --all` message. Pull request #3483 by David
  Rodríguez.
* Fix incorrect bundler version being required. Pull request #3458 by
  David Rodríguez.
* Fix gem install from a gemdeps file with complex dependencies.
  Pull request #3054 by Luis Sagastume.

=== 3.1.2 / 2019-12-20

Minor enhancements:

* Restore non prompting `gem update --system` behavior. Pull request #3040
  by David Rodríguez.
* Show only release notes for new code installed. Pull request #3041 by
  David Rodríguez.
* Inform about installed `bundle` executable after `gem update --system`.
  Pull request #3042 by David Rodríguez.
* Use Bundler 2.1.2. Pull request #3043 by SHIBATA Hiroshi.

Bug fixes:

* Require `uri` in source.rb. Pull request #3034 by mihaibuzgau.
* Fix `gem update --system --force`. Pull request #3035 by David
  Rodríguez.
* Move `require uri` to source_list. Pull request #3038 by mihaibuzgau.

=== 3.1.1 / 2019-12-16

Bug fixes:

* Vendor Bundler 2.1.0 again. The version of Bundler with
  RubyGems 3.1.0 was Bundler 2.1.0.pre.3. Pull request #3029 by
  SHIBATA Hiroshi.


------------------------------------------------------------------------------

RubyGems installed the following executables:
        /usr/bin/gem
        /usr/bin/bundle

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for Ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.
```

# リンク一覧

- https://redmine.jp
- https://rubygems.org
- http://guide.redmine.jp/RedmineInstall/
    - cygwinなので読み替えは必要だけど手本となるページ
- http://guide.redmine.jp/RedmineBackupRestore/#sqlite
    - バックアップとリストアについて
- http://guide.redmine.jp/RedmineUpgrade/
    - アップグレードについて
- https://qiita.com/jnchito/items/d3257a5f46f4f1aee200
    - bundleコマンド実行時のメッセージからたどり着いた
    - bundle3を見据えた非推奨なオプションなど
-  https://www.redmine.org/projects/redmine/wiki/HowTo_install_rmagick_gem_on_Windows
    - rmagickのインストール手順