私がはるか昔受け持ったプロジェクトは見事に失敗したが、ひとつだけ成果を残した。 それは今でいう課題管理システムを作ったことである。これは Notes 4 で作った。時代を察してもらいたい。
今となってはバグを課題管理システムで扱うのは当然だろう。そして市販製品も、オープンソースもいろいろある。 課題管理システムの一番いいところは、課題が目に見えることだ。当たり前かもしれないが、 その当たり前のことがなかなかできないのだ。
課題管理システムにはいろいろある。 Effective Debugging という書籍によれば、 最初の項目で「項目1:あらゆる項目を課題管理システムで使う」ということで、 いの一番に課題管理システムをもってきている。課題管理システムは Issue Tracking System の日本語訳で、 ITS と略して呼ばれることもある。商用製品もオープンソースのものもある。上述書をもとに、 主なオープンソースの ITS を次の表にまとめた。
名称 | 記述言語 | 紹介サイト |
---|---|---|
Bugzilla | Perl | https://www.bugzilla.org |
Launchpad | Python? | https://launchpad.net |
OTRS | Perl 5.16.0 | http://www.otrs.org/ |
Redmine | Ruby | http://www.redmine.org/ |
Trac | Python 2.7 | https://trac.edgewall.org/ |
自分でインストールできそうなものは Redmine と Trac であった。以下はその苦闘の記録である。 なおインストール環境は私の個人パソコンで、 Windows 10 Home Edition で動いている WSL2 の Ubuntu 20.04 である。
Trac は課題管理システムのなかでは古株だろう。以下、
https://qiita.com/nonNoise/items/29e47160626bf964c2a4
を参考にしてインストールを試みる。
Python 関係のパッケージマネージャとして普段わたしは Anaconda を使っているが、 http://anaconda.org/ には登録されていないようだ。 もともと Anaconda は科学技術計算中心のパッケージであるから、trac はないのも無理はないだろう。 したがって、pip で入れる。
$ sudo pip3 install trac Collecting trac Downloading Trac-1.4.2.tar.gz (5.6 MB) |████████████████████████████████| 5.6 MB 3.9 MB/sERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; → sys.argv[0] = '"'"'/tmp/pip-install-aeuq36d2/trac/setup.py'"'"'; → __file__='"'"'/tmp/pip-install-aeuq36d2/trac/setup.py'"'"'; →f=getattr(tokenize, '"'"'open'"'"', open)(__file__); →code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close(); →exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-aeuq36d2/trac/pip-egg-info cwd: /tmp/pip-install-aeuq36d2/trac/ Complete output (1 lines): Trac doesn't support Python 3 (yet) ---------------------------------------- ERROR: Command errored out with exit status 1: → python setup.py egg_info Check the logs for full command output.
なんじゃこりゃー! Trac は Python 3 では動かないのか? 人生には3つの坂があるのだ。そう、まさかがある。
自分で Python3 にコードを書き換えた方もいて尊敬する。しかし、私にはできない。
いや、ひょっとして Python 2.7 を入れれば使えるのではないか。 私は anaconda で環境を作っているので、2.7 も入れられる。
(base) $ conda create -n py27 python=2.7 (base) $ conda activate py27 (py27) $ python Python 2.7.18 :: Anaconda, Inc. (py27) $ sudo pip3 install trac
しかし、やはり結果は同じエラーである。
さきほどのエラーメッセージを見ると、
/usr/bin/python3 -c 引数
なので、仮想環境で Python 2 をインストールしてもどうにもならないのかもしれない。
次の候補は Redmine である。Ruby, Ruby on Rails (RoR) を入れないといけないから、しきいが高い。 ただ昔は RoR も少しやっていたから、復習の意味でやってみよう。 なお、以下は自分のためだけに運用するので SQLite3 を使うが、業務で使うのであれば PostgresQL や MySQL 、 あるいは他の商用データベースを使うべきである。それから、ウェブサーバも WEBrick を使っているが、 これも業務用ではないから使っているので、業務用では他の Webサーバを使うべきである。 インストールは下記の記述を参考にした。
まず、ruby 周りを確認する。ruby や rbenv、Node.js、SQLite3 がインストールされていることを確認する。
次に gem で Rails をインストールする。
$ gem install rails (中略) 33 gems installed
大量のメッセージが出てくるが、うまくインストールされていることを祈る。
http://guide.redmine.jp/RedmineInstall/
https://www.redmine.org/projects/redmine/wiki/Download
から 4.2.0 をダウンロードする。
なんとかできた。そして、上記を展開し、config/database.yml を SQLite3 用に編集した。 次は bundler をインストールする。
(base) $ gem install bundler Fetching bundler-2.2.15.gem Successfully installed bundler-2.2.15 Parsing documentation for bundler-2.2.15 Installing ri documentation for bundler-2.2.15 Done installing documentation for bundler after 6 seconds 1 gem installed
そして指示にしたがって、Redmineを実行するために必要なすべてのgemをインストールしようとした。
$ 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 --local without 'development test'`, → and stop using this flag (中略) An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: sqlite3 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
うーん、sqlite3 が入らないのか。あるいは見つけられないのか。やはり Ruby on Rails は敷居が高い。 それでも、もう少し頑張ってみるか。
$ gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/' Building native extensions. This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. current directory: ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sqlite3-1.4.2/ext/sqlite3 ~/.rbenv/versions/2.7.2/bin/ruby -I ~/.rbenv/versions/2.7.2/lib/ruby/2.7.0 → -r ./siteconf20210405-1708-aanntj.rb extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'brew install sqlite3', 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' and check your shared library search path (the location where your sqlite3 shared library is located). *** extconf.rb failed *** $ sudo apt install libsqlite3-dev $ gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/' Building native extensions. This could take a while... Successfully installed sqlite3-1.4.2 Parsing documentation for sqlite3-1.4.2 Installing ri documentation for sqlite3-1.4.2 Done installing documentation for sqlite3 after 0 seconds 1 gem installed $ bundle config set --local without 'test development' You are replacing the current local value of without, which is currently "test:development"
ソースコードからインストールするのは荷が重そうだ。apt でインストールできないものか。
$ sudo apt cache redmine bugwarrior/focal 1.7.0-1 all Pull tickets from bug trackers into taskwarrior hashcat/focal 5.1.0+ds1-2 amd64 World's fastest and most advanced password recovery utility python3-redminelib/focal 2.2.1-1 all Python library for the Redmine RESTful API (Python 3) redmine/focal 4.0.6-2 all 柔軟なプロジェクト管理用 web アプリケーション redmine-mysql/focal 4.0.6-2 all metapackage providing MySQL dependencies for Redmine redmine-pgsql/focal 4.0.6-2 all metapackage providing PostgreSQL dependencies for Redmine redmine-plugin-custom-css/focal 0.1.7+dfsg-1 all Redmine plugin to add custom CSS editable through web interface redmine-plugin-local-avatars/focal 1.0.5-1 all Redmine plugin to add local avatar support redmine-plugin-pretend/focal 0.0.2+git20130821-5 all Redmine plugin to allow admins to log-in as users redmine-sqlite/focal 4.0.6-2 all metapackage providing sqlite dependencies for Redmine
必要なのは redmine と redmine-sqlite だろうか。
$ sudo apt install redmine redmine-sqlite (中略)
<はい>を選択する。
パッケージの設定
sqlite3 が選ばれている状態で<了解>をクリックする。
さてこれでインストールが終わったが、その先何をしていいかわからない。わかっていることは、次の二つだ。
Redmine がインストールされた場所 /usr/share/redmine
設定ファイルが配置された場所 /etc/redmine/default
もういきなり WEBrick を動かしたらどうなるだろうか。
$ bundle exec rails server webrick -e production Could not locate Gemfile or .bundle/ directory
Gemfile はどこにあるのだろう。/var/lib/redmine には Gemfile.lock があったが、Gemfile はない。 /usr/share/redmine にあった。
$ cd /usr/share/redmine $ bundle exec rails server webrick -e production Could not find concurrent-ruby-1.1.6 in any of the sources Run `bundle install` to install missing gems. $ bundle install There was an error while trying to write to `/usr/share/redmine/.bundle/config`. It is likely that you need to grant write permissions for that path. $ sudo bundle install 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. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`. Using rake 13.0.1 (中略) Using sqlite3 1.4.2 Bundle complete! 18 Gemfile dependencies, 55 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
本当にいいのだろうか。
$ sudo bundle exec rake generate_secret_token $ RAILS_ENV=production $ export RAILS_ENV $ sudo bundle exec rake db:migrate (ウォーニング10行以上) $ sudo bundle exec rake redmine:load_default_data (ウォーニング10行以上) Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, → he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, → th, tr, uk, vi, zh, zh-TW [en] ja (ウォーニング4行) Some configuration data is already loaded. $ sudo mkdir files $ sudo mkdir log $ sudo mkdir tmp/pdf $ sudo bundle exec rails server webrick -e production => Booting WEBrick => Rails 5.2.3 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options (ウォーニング6行) [2021-04-05 16:51:57] INFO WEBrick 1.6.0 [2021-04-05 16:51:57] INFO ruby 2.7.0 (2019-12-25) [x86_64-linux-gnu] [2021-04-05 16:51:57] INFO WEBrick::HTTPServer#start: pid=330 port=3000 (ウォーニング14行) 127.0.0.1 - - [05/Apr/2021:16:52:33 JST] "GET / HTTP/1.1" 200 4483 - -> / 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /stylesheets/jquery/jquery-ui-1.11.0.css?1576842242 HTTP/1.1" 200 27766 http://localhost:3000/ -> /stylesheets/jquery/jquery-ui-1.11.0.css?1576842242 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /javascripts/application.js?1576842242 HTTP/1.1" 200 26866 http://localhost:3000/ -> /javascripts/application.js?1576842242 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /javascripts/responsive.js?1576842242 HTTP/1.1" 200 2002 http://localhost:3000/ -> /javascripts/responsive.js?1576842242 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /stylesheets/responsive.css?1576842242 HTTP/1.1" 200 18111 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /stylesheets/application.css?1576842242 HTTP/1.1" 200 61522 http://localhost:3000/ -> /stylesheets/application.css?1576842242 http://localhost:3000/ -> /stylesheets/responsive.css?1576842242 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /javascripts/jquery_ujs.js?1531227323 HTTP/1.1" 200 21600 http://localhost:3000/ -> /javascripts/jquery_ujs.js?1531227323 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /javascripts/jquery.min.js?1555656755 HTTP/1.1" 200 137549 127.0.0.1 - - [05/Apr/2021:16:52:34 JST] "GET /javascripts/jquery-ui.min.js?1502019941 HTTP/1.1" 200 312014 http://localhost:3000/ -> /javascripts/jquery-ui.min.js?1502019941 http://localhost:3000/ -> /javascripts/jquery.min.js?1555656755 127.0.0.1 - - [05/Apr/2021:16:52:35 JST] "GET /images/arrow_down.png HTTP/1.1" 200 189 http://localhost:3000/stylesheets/application.css?1576842242 -> /images/arrow_down.png (以下略)
果たして http://localhost:3000/ にアクセスして表示できるだろうか。
うまくいった!