Windows10 に Ruby on Railsを入れてみた。


動機

仕事中、手が空いたので、技術ニュースを漁っていたところ、 Rails6 が出ていたことに大興奮な私。(普段はSier)
そこで、割と自由な私は社内のWindows端末にRuby on Rails6(以下Rails)を入れてみました。

動作環境

  • Windows 10 Pro
  • VS Code
  • Ruby 2.6.5 (投稿時最新)
  • Rails 6.0.1

でーす。

必要なものインスコ

VS Code

ここから入手しましょう。

Git

ここから入手しましょうぜ。

Ruby

インストーラーはこちら

インストールが終わったら、VSCodeのコンソールからコマンド叩いていきましょう。
私の場合はbashでなくVSCode上でpowershellで色々実行しました。

Rubyのバージョン確認

C:\>ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
C:\>gem -v
3.0.3

入った。

Railsインストール

C:\>gem install rails 
...
40 gems installed
C:\>rails -v
Rails 6.0.1

入った入った。

さて動くか試してみようぜ!

Dドライブ直下でインスコしているように書いていますが適宜読み替えてください。

D:\>rails new sample_app
In Gemfile:
  sqlite3
         run  bundle binstubs bundler
Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem
sources
listed in your Gemfile.
       rails  webpacker:install
Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem
sources listed in your Gemfile.
Run `bundle install` to install missing gems.

色々動いてるけど最後の最後にエラーだぜ。
デフォのDB、sqlite3が入ってないってさ。とりあえず指示通り入れます。

D:\>gem install sqlite3
1 gem installed

入った。

D:\sample_app>bundle install
Bundle complete! 14 Gemfile dependencies, 70 gems now installed.

入ったー。

D:\sample_app>rails s
=> Booting Puma
=> Rails 6.0.1 application starting in development
=> Run `rails server --help` for more startup options
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Exiting

怒られた。webpackがないって。ぐぐったら、情報出てきた。rails webpacker:installで良さそう。

D:\sample_app>rails webpacker:install
Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

Yarnがないって。
ご丁寧にURL貼ってあったから、ここから入れようぜ。

...数分後

入れた。VS Code再起動しましょう

D:\sample_app>rails webpacker:install
Done in 7.19s.
Webpacker successfully installed

入った。

D:\sample_app>rails s
Puma starting in single mode...

動いた!

で動くよーに、なりまんた。でめたしでめたし。

ご覧頂きありがとうございました。