すがブロ

sugamasaoのhatenablogだよ

Rails 4.1が 64bit版のRubyをインストールしたWindowsで動かないヨォ〜〜

Windowsで 64bit版Rubyを使って Rails 4.1 を攻めてみた結果

動かないけど動かすようにするのは簡単だった

環境

> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby200/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: C:/Ruby200/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby200/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby200/lib/ruby/gems/2.0.0
     - C:/Users/sugamasao/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

動かないの再現

> rails new windows_sample
> cd windows_sample
> ruby ./bin/rails s
C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:199:in `rescue in create_default_data_source': No timezone data source could be found. To resolve this, either install TZInfo::Data (e.g. by running `gem install tzinfo-data`) or specify a zoneinfo directory using `TZInfo::DataSource.set(:zoneinfo, zoneinfo_path)`. (TZInfo::DataSourceNotFound)
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:196:in `create_default_data_source'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:62:in `block in get'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:61:in `synchronize'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:61:in `get'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:601:in `data_source'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:114:in `get'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone_proxy.rb:84:in `real_timezone'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone_proxy.rb:52:in `period_for_utc'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:524:in `current_period'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/object/try.rb:45:in `public_send'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/object/try.rb:45:in `try'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:223:in `utc_offset'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in `block in []'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in `tap'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in `[]'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/time/zones.rb:60:in `find_zone!'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/railtie.rb:20:in `block in <class:Railtie>'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `instance_exec'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `run'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:55:in `block in run_initializers'
  from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
   from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each'
   from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:54:in `run_initializers'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/application.rb:288:in `initialize!'
   from z:/tmp/rails_41/windows_sample/config/environment.rb:5:in `<top (required)>'
  from z:/tmp/rails_41/windows_sample/config.ru:3:in `require'
    from z:/tmp/rails_41/windows_sample/config.ru:3:in `block in <main>'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
  from z:/tmp/rails_41/windows_sample/config.ru:in `new'
    from z:/tmp/rails_41/windows_sample/config.ru:in `<main>'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:50:in `app'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:130:in `log_to_stdout'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in `start'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in `block in server'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
  from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
   from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
  from ./bin/rails:4:in `require'
    from ./bin/rails:4:in `<main>'

要約すると以下のことでおこになってる

No timezone data source could be found. To resolve this, either install TZInfo::Data
(e.g. by running `gem install tzinfo-data`)

ようするに tzinfo-data がないということ。 で、Gemfileを見ると、実は書いてある。

source 'https://rubygems.org'
  : 
  : 
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

なのにインストールされてないというのだ

解決方法

64bit版のRubyはplatformsが x64_mingw になるので、これを追加してやれば良い。つまりこうする

source 'https://rubygems.org'
  : 
  : 
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

これを書いたあと、おもむろに bundle update すると tzinfo-dataがインストールされる。そして、rails serverも無事に動く。

ちなみに、masterではもう修正されている(4.1.1になったら直るのかな)。

どうしても書かなくては行けない事柄

パーフェクトRuby (PERFECT SERIES 6)

パーフェクトRuby (PERFECT SERIES 6)

そしてこれ

Webアプリエンジニア養成読本[しくみ、開発、環境構築・運用…全体像を最新知識で最初から! ] (Software Design plus)

Webアプリエンジニア養成読本[しくみ、開発、環境構築・運用…全体像を最新知識で最初から! ] (Software Design plus)

書かなくても良い事柄

結婚しました。