LoginSignup
0
0

More than 3 years have passed since last update.

Rails version: 6.0.2.1 新規アプリ作成〜サーバー立ち上げまで

Last updated at Posted at 2020-02-16

Progate【Ruby on Rails5 道場コース I】に沿って
アウトプットも兼ねて実際にアプリ作成していこうと思いきや
ちょっとつまづいた部分があったので記録していきます。

新規アプリ作成

ターミナルでrails new 【新規作成したいアプリ名】を入力。
(例えば私の場合はrails new agametter_app)※ひたすら推しを崇める言葉をツイートするゴミアプリ

qiita.rb
$ rails new 【新規作成したいアプリ名】
qiita.rb
create  
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
      create  Gemfile
         run  git init from "."
*
*
(省略)
*
*
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, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted
       rails  webpacker:install
sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/

なんとか作成できたようです。
(後半辺りで「Node.jsダウンロードしろ」って言われてることに後から気付くという…。)

作成したアプリに入る

アプリ名の頭にcdを付けて入る

qiita.rb
$ cd 【新規作成したアプリ名】

※自分のユーザー名の後ろにアプリ名が入ればOK
        ↓  ↓  ↓
lancai@oja 【新規作成したアプリ名】 $

早速サーバーを立ち上げよう

railsのサーバーを立ち上げます。

qiita.rb

$ rails s

いい調子に進んでる…!

qiita.rb
=> Booting Puma
=> Rails 6.0.2.1 application starting in development 
=> Run `rails server --help` for more startup options
Exiting
Traceback (most recent call last):
    77: from bin/rails:3:in `<main>'
    76: from bin/rails:3:in `load'
    75: from /Users/lancai/agametter_app/bin/spring:15:in `<top (required)>'
    74: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    73: from 
*
*
(省略)
*
*
 1: from /Library/Ruby/Gems/2.6.0/gems/webpacker-4.2.2/lib/webpacker/configuration.rb:91:in `load'
/Library/Ruby/Gems/2.6.0/gems/webpacker-4.2.2/lib/webpacker/configuration.rb:95:in `rescue in load': Webpacker configuration file not found /Users/lancai/agametter_app/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /Users/lancai/agametter_app/config/webpacker.yml (RuntimeError)
lancai@oja agametter_app % rails webpacker:install
sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/

「Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/」

一番下の行でどうやら「Node.jsをダウンロードしろ」と命令されているようなので、指定されたURLに飛んでダウンロードします。
スクリーンショット 2020-02-16 22.17.37.png
自分が使用しているOSを選びます。

ダウンロードができたらインストールします。
(インストールできない場合は「システムの環境設定」→「セキュリティとプライバシー」→「一般」タブ→左下のカギアイコン→パスワード認証→ダウンロードしたアプリケーションの実行許可により、インストールが可能となります。)
スクリーンショット 2020-02-16 22.22.44.png

webpackerのインストール

さて、インストールが終わったのでターミナルに入力していきます。

qiita.rb

$ rails webpacker:install
qiita.rb
Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

今度はYarnが必要みたいなので
下記を入力してインストールしていきます。

qiita.rb
$ brew install yarn
qiita.rb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
awscli@1                                 katago
==> Updated Formulae
ruby-build                              jsonschema2pojo
abcmidi                                  kube-aws
*
*
(省略)
*
*
├─ unpipe@1.0.0
├─ utils-merge@1.0.1
├─ wbuf@1.7.3
├─ webpack-dev-middleware@3.7.2
├─ webpack-dev-server@3.10.3
├─ websocket-extensions@0.1.3
├─ ws@6.2.1
├─ yargs-parser@11.1.1
└─ yargs@12.0.5
  Done in 11.25s.
Webpacker successfully installed 🎉 🍰

わあ、絵文字がカワイイ…(ほっこり)

インストールが完了したので、サーバー立ち上げに戻ります。

qiita.rb

$ rails s
qiita.rb
=> Booting Puma
=> Rails 6.0.2.1 application starting in development 
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 4.3.1 (ruby 2.6.3-p62), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://127.0.0.1:3000
* Listening on tcp://[::1]:3000
Use Ctrl-C to stop
Started GET "/home/top" for ::1 at 2020-02-16 21:23:36 +0900
   (3.2ms)  SELECT sqlite_version(*)
*
*
(省略)
*
*
puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
Started GET "/" for ::1 at 2020-02-16 21:23:48 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendering /Library/Ruby/Gems/2.6.0/gems/railties-6.0.2.1/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /Library/Ruby/Gems/2.6.0/gems/railties-6.0.2.1/lib/rails/templates/rails/welcome/index.html.erb (Duration: 9.6ms | Allocations: 197)
Completed 200 OK in 13ms (Views: 10.6ms | ActiveRecord: 0.0ms | Allocations: 950)

スクリーンショット 2020-02-16 22.46.37.png

URL http://localhost:3000/
にアクセスして写真のようなページが表示されたらサーバーの立ち上げは無事成功!ということになります。

ひとまず、お疲れ様でした

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