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/)
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.
① 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)```
(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.
## 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 ●●●●
I did "ruby -v" to check if the version is installed.
(1) Execute the following command to install.
gem install bundler
① Install and start my SQL.
brew install mysql
② Check my SQL
## 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 22.214.171.124`**
① Specify the file destination you want to create
② 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:
① 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 http://localhost:3000 → 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.