Windows7(64bit)でRailsがうまく動いてくれない

今日は Rails だ。試しに簡単な Web アプリを作ってみるよ。蔵書を管理するアプリにしよう。名前は Librarian だ。
と、意気込んだところだけど、結果から言うをうまくいかなかった。以下その顛末。

まずは Rails のプロジェクトを作る。

^o^ > rails new Librarian

このコマンドでずら~っとファイル一式が生成される。とりあえずはこれで git のリポジトリを作って最初のコミット。

^o^ > cd Librarian

^o^ > git init
Initialized empty Git repository in C:/Users/hiro/Documents/w/Librarian/.git/

^o^ > git add .
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory.
(以下略)

^o^ > git commit -m "First commit."
[master (root-commit) 167a985] First commit.
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory.
(以下略)

で、次は scaffold。

^o^ > ruby bin/rails generate scaffold book title volume author
DL is deprecated, please use Fiddle
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/data_source.rb:1
82:in rescue in create_default_data_source': No source of timezone data could b
e found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving th
is error.
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:179:in create_default_data_source'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:40:in block in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:39:in synchronize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:39:in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:629:in data_source'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:92:in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone_proxy.rb:67:in real_timezone'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone_proxy.rb:30:in period_for_utc'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:549:in current_period'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/object/try.rb:45:in public_send'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/object/try.rb:45:in try'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:223:in utc_offset'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in block in []'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in tap'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in []'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/time/zones.rb:60:in find_zone!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/railtie.rb:20:in block in '
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:30:in instance_exec'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:30:in run'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:55:in block in run_initializers'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in block in tsort_each'

        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in block (2 levels) in
each_strongly_connected_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in each_strongly_connec
ted_component_from'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in block in each_strong
ly_connected_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in each'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in each_strongly_connec
ted_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in tsort_each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:54:in run_initializers'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:288:in initialize!'
        from C:/Users/hiro/Documents/w/Librarian/config/environment.rb:5:in '
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:264:in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:264:in require_environment!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:147:in require_application_and_environment!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:133:in generate_or_destroy'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:51:in generate'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:40:in run_command!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands.rb:17:in '
        from bin/rails:4:in require'
        from bin/rails:4:in 
'

なんかエラーが出た。どうやら timezone のデータが見つからない、といっているらしい。ついでに(親切にも)http://tzinfo.github.io/datasourcenotfound を見ればいいよ、とも。
早速ページにアクセスしてみる。すると、あった、Gemfile にちょっと記述を追加すればいいらしい。

If you are using a 64-bit version of Ruby on Windows, then add :x64_mingw to the list of platforms as follows:

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

指示通り、Gemfile に :x64_mingw を追記して、buldle install を実行。

^o^ > ruby bin/bundle install
DL is deprecated, please use Fiddle
Using rake 10.3.2
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.5
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.1
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.1
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.1
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.1
Using activemodel 4.1.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.1
Using coffee-script-source 1.7.0
Using execjs 2.2.1
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.1
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.1
Using jquery-rails 3.1.1
Using bundler 1.6.3
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.1
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.1
Your bundle is complete!
Use bundle show [gemname] to see where a bundled gem is installed.

だけどなんだかちゃんとインストールされたような気配がない。試しにもう一度 scaffold をやってみる。

^o^ > ruby bin/rails generate scaffold book title volume author
DL is deprecated, please use Fiddle
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/data_source.rb:1
82:in rescue in create_default_data_source': No source of timezone data could b
e found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving th
is error.
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:179:in create_default_data_source'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:40:in block in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:39:in synchronize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/dat
a_source.rb:39:in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:629:in data_source'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:92:in get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone_proxy.rb:67:in real_timezone'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone_proxy.rb:30:in period_for_utc'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/tim
ezone.rb:549:in current_period'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/object/try.rb:45:in public_send'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/object/try.rb:45:in try'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:223:in utc_offset'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in block in []'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in tap'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/values/time_zone.rb:396:in []'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/core_ext/time/zones.rb:60:in find_zone!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/act
ive_support/railtie.rb:20:in block in '
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:30:in instance_exec'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:30:in run'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:55:in block in run_initializers'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in block in tsort_each'

        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in block (2 levels) in
each_strongly_connected_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in each_strongly_connec
ted_component_from'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in block in each_strong
ly_connected_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in each'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in each_strongly_connec
ted_component'
        from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in tsort_each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/in
itializable.rb:54:in run_initializers'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:288:in initialize!'
        from C:/Users/hiro/Documents/w/Librarian/config/environment.rb:5:in '
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:264:in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/ap
plication.rb:264:in require_environment!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:147:in require_application_and_environment!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:133:in generate_or_destroy'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:51:in generate'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands/commands_tasks.rb:40:in run_command!'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/co
mmands.rb:17:in '
        from bin/rails:4:in require'
        from bin/rails:4:in 
'

やっぱり同じじゃないか。
仕方がないから、tzinfo-data っていう gem を直接インストールする。

^o^ > gem install tzinfo-data
Fetching: tzinfo-data-1.2014.5.gem (100%)
Successfully installed tzinfo-data-1.2014.5
Parsing documentation for tzinfo-data-1.2014.5
Installing ri documentation for tzinfo-data-1.2014.5
Done installing documentation for tzinfo-data after 3 seconds
1 gem installed

よし、インストールできた。これで大丈夫だろう。

^o^ > ruby bin/rails generate scaffold book title volume author
DL is deprecated, please use Fiddle
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.1/lib/tzinfo/data_source.rb:1
82:in `rescue in create_default_data_source': No source of timezone data could b
e found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving th
is error.
(以下略)

だめだ~!ちゃんと tzinfo-data はインストールできてるのに何で見つからないんだ。

もしかして Ruby 2.0.0 と Rails 4.1.1 って相性が悪いのか?

追記(2014/07/01)

昨日ダメだった Rails だけど、今日会社の PC (Windows7 32bit、Ruby 2.0.0 32bit)でこっそりやってみたらあっさりとうまくいってしまった。64bit版がダメだってこと?

カテゴリー: Ruby パーマリンク

1 Response to Windows7(64bit)でRailsがうまく動いてくれない

  1. ピンバック: UbuntuでもRailsがうまく動いてくれない→解決 | blog.PanicBlanket.com

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください