[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)

at first

I have built an environment for Ruby on Rails, so I will record it.

[Building environment] ・ Rails6 ・ Ruby 2.6.3

[Machine specs] ・ MacOS Catalina -Version 10.15.3 ・ IMac (retina 4K, 21.5-inch, 2019) · Processor 3 GHz 6 core Intel Core i5 ・ Memory 8GB

[Editor used] VScode (https://azure.microsoft.com/ja-jp/products/visual-studio-code/)

Construction procedure

Install Command Line Tools

You'll need your Apple ID here. If you have forgotten your Id / password, please prepare them in advance.

① Log in to Apple's developer account page https://developer.apple.com/account/#/welcome

② From See more downloads to the download list page https://developer.apple.com/download/more/

→ Download the Command Line Tools compatible with the OS.

Homebrew installation

① Go to the official website of Homebrew and paste the command described in "Terminal". (Homebrew official website) https://brew.sh/index_ja

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

 ② Confirmation of Homebrew installation
 I'm worried that the installation was successful, so I'll check it.

```brew -v```

 * In my case, it was the following command.

#### **`Homebrew 2.2.17`**

Homebrew/homebrew-core (git revision 572fc; last commit 2020-05-24)```

Install rbenv

(1) Install so that you can manage the version of ruby.

brew install rbenv ruby-build

(2) After the installation is completed, please check with the following command.

rbenv -v

rbenv 1.1.2

## Ruby installation
 From here, let's install Ruby.
 * Ruby may already be installed depending on the user.

 (1) Check if it is installed.

```ruby -v```

 * In my case, it was the following command.

#### **`ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]`**

I wanted to install it already, but if it doesn't seem to be installed, please install it below.

② If it is not installed Check the version of Ruby that can be installed with the following command.

rbenv install --list

If you can confirm, execute the following, The number specifies the version executed by "rbenv install --list"

rbenv install ●●●● rbenv global ●●●● rbenv rehash ruby -v

I did "ruby -v" to check if the version is installed.

Bundler installation

(1) Execute the following command to install.

gem install bundler

② Check.

bundle -v

install my SQL

① Install and start my SQL.

brew install mysql

② Check my SQL

mysql.server start

## Rails installation

 ① Let's create a directory
 ●, enter any file name.

```mkdir ~/●●●●●●●```

 ② Move to the created folder

```cd ~/workspace```

 ③ Create a Gemfile

```bundle init```

 ④ Edit / uncomment the contents of Gemfile
 There is a "Gemfile" in the folder created with "mkdir ~ / ●●●●●●●".
 Start it with your editor software.

 In the file, ``` # gem" rails "``` is written as a memo, so please uncomment it.

 ⑤ Install Rails

```bundle install --path=vendor/bundle```

 ⑥ Check if Rails is installed

```bundle exec rails -v```

 * In my case, it was the following command.

#### **`Rails`**

Create a test file in Rails

① Specify the file destination you want to create

cd desktop

② Create a new file with Rails ● is an arbitrary file name.

rails new ●●●●●


I got an error here !! The cause was "Error in Webpacker". Do the following:

Installing Webpacker

① yarn is installed

brew install yarn

(2) Execute the following command.


 But "yarn" is not installed!
 Since it is said, execute the following command.

## Launch Rails

 ① Execute the command to launch the browser
 Execute the following command

```rails s```

 ② Start the local server


 → It started up safely.
 Was good!

# Reference article
 [Ruby on Rails environment construction for Ruby beginners [Mac]](https://qiita.com/TAByasu/items/47c6cfbeeafad39eda07)
 [Install Homebrew](https://qiita.com/zaburo/items/29fe23c1ceb6056109fd)
 [Error in Rails6 Webpacker](https://qiita.com/libertyu/items/1eb74adc817ab8971100)

 The reference article was very helpful.
 Thank you very much.

Recommended Posts

[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)
Ruby on Rails development environment construction on M1 Mac
Ruby on Rails 6.0 environment construction memo
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
[Personal memo] Ruby on Rails environment construction (Windows)
[Ruby on Rails] Let's build an environment on mac
Rails6 development environment construction [Mac]
Rails engineer environment construction ruby2.7.1
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
How to solve the local environment construction of Ruby on Rails (MAC)!
[Rails / MySQL] Mac environment construction
[Environment construction] Ruby on Rails 5.2 system development environment construction [within 1 hour]
Ruby on Rails environment construction using VirtualBox, Vagrant, cyberduck
Ruby environment construction summary ~ mac version ~
Rails on Docker environment construction procedure
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
Ruby on Rails --From environment construction to simple application development on WSL2
Spring Boot environment construction memo on mac
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Ruby on Rails installation method [Mac edition]
Java development environment construction memo on Mac
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
[Ruby on Rails] Japanese notation of errors
Rails & React & Webpacker & MySQL Environment Construction Manual
CentOS8.2 (x86_64) + ruby2.5 + Rails5.2 + MariaDB (10.3.17) environment construction
Environment construction of Ruby on Rails from 0 [Cloud9] (From Ruby version change to Rails installation)
[Error] Switch environment construction to use Ruby on Rails oss (open source)
[Ruby On Rails] About RubyAws :: Sigv4 :: Errors :: MissingCredentialsError
Building a Ruby environment for classes on Mac
Install Ruby / Rails on Mac M1 Big Sur 2021-01
Rails Docker environment construction
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
Build a Ruby on Rails development environment on AWS Cloud9
Docker the development environment of Ruby on Rails project
[Ruby] I can't install puma on Mac [Rails, etc.]
[Ruby on Rails] From MySQL construction to database change
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
Ruby on Rails basic learning ①
Ruby on rails learning record-2020.10.07 ②
[Docker] Rails 5.2 environment construction with docker
Ruby on rails learning record-2020.10.07 ①
Cancel Ruby on Rails migration
Offline environment construction Ruby edition
[Super easy] Ruby environment construction
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
Rails + MySQL environment construction with Docker
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)