LoginSignup
0
0

More than 1 year has passed since last update.

# Ruby on Rails(ruby3.0系) の環境構築 ※Windows

Last updated at Posted at 2022-06-09

この記事ではdockerでの仮想環境で構築するわけではなくCドライブにそのままrubyをインストールして環境構築をします。今からrubyやrailsを始めるという方向けです。

バージョン

ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x64-mingw32]
Rails 7.0.3


rubyのインストール

ruby公式 から Ruby+Devkit 3.0.4-1 (x64) をクリックしてダウンロードして下さい。
※バージョン確認コマンド
ruby -v
※rubyのバージョンが3.1系だとrails new プロジェクト名でrailsのプロジェクトを立ち上げる時に以下のエラーが発生してプロジェクトが上手く作られず、rails sで始めることが出来なくなります。

Errno::ENOENT: No such file or directory - bs_fetch:open_current_file:open 
bin/rails:4:in `<main>'
~~~
省略
~~~
Bundle complete! 15 Gemfile dependencies, 71 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
       rails  webpacker:install
rails aborted!
Errno::ENOENT: No such file or directory - bs_fetch:open_current_file:open
bin/rails:4:in `<main>'
(See full trace by running task with --trace)

対処方

  • rubyのバージョンを3.0系に下げる
  • linux環境で構築する

railsのインストール

C:\Usersユーザー名> gem install rails 

※バージョン確認コマンド
rails -v


railsプロジェクトの作成

rubyとrailsのインストールを終えたら以下のコマンドでrailsのプロジェクトを作成します。
※OneDriveの配下で作成するとエラーになりました。

C:Users\ユーザー名\任意のフォルダ>rails new プロジェクト名

サーバを起動する

C:\Users\ユーザー名\任意のフォルダ>cd プロジェクト名
C:\Users\ユーザー名\任意のフォルダ/プロジェクト名>rails s

(http://127.0.0.1:3000/)
(http://localhost:3000/)
上のリンク(どちらでもよい)を開いて下の画面が開けば成功です。
スクリーンショット 2022-06-09 141256.png


今回はネットにrubyの3系のrailsの立ち上げが無かったのでQiitaに始めて書いてみました。
データベースとの連携は他の方が色々とあげていらっしゃるのでここでは省きたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0