Environment construction of Ruby on Rails from 0 [Cloud9] (From Ruby version change to Rails installation)

Ruby on Rails environment construction (Cloud9)

This article is an article that explains how to build a Ruby on Rails environment so that even beginners can do it without hesitation.

Ruby on Rails is used in extensive development. It is often adopted by Japanese startups, and tabelog, note, accounting software freee, etc. are also developed by Ruby on Rails.

For such Ruby on Rails, version 6.0 was released in August 2019, and version 6.1 was released in December 2020. In addition, Ruby itself has undergone a major update to version 3.0 in December 2020, adding new features.

Here, we will explain how to build an environment for ** Ruby 3.0 and Ruby on Rails 6.1.1 **.

environment

--Cloud9 (Compatible with both Mac and Windows) --Article on how to build an environment on Mac is also available.

Check the Ruby version

Sign in to the console from the URL below and launch Cloud9.

https://us-east-2.console.aws.amazon.com/console/

Launch Terminal on Cloud9 and execute the following command to check the Ruby version.

ruby -v

The numbers are displayed as shown below.

ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

Here you can see that the Ruby environment is "** 2.6.3 **".

Change Ruby version

Now let's change the Ruby version from here.

Use rvm, a Ruby version control tool.

Check the installed Ruby version with the following command.

rvm list

The execution result is as follows.

rvm list
=* ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

It also lists the Ruby versions that can be installed with the following command.

rvm list known

Check the execution result to confirm that you have the version you want to install.

rvm list known

//====Abbreviation====

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3]
ruby-head

//====Abbreviation====

If you don't have the version you want to install here, you'll need to update rvm.

To update, execute the get command as shown below.

rvm get latest
rvm get latest

//====Abbreviation====

Thanks for installing RVM 
Please consider donating to our open collective to help us maintain RVM.

  Donate: https://opencollective.com/rvm/donate


RVM reloaded!

Check the version of rvm you have installed.

rvm -v
rvm 1.29.10 (1.29.10) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Make sure you have the version you want to install again.

rvm list known

//====Abbreviation====

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0] #← Version you want to install
ruby-head

//====Abbreviation====

Then run the following command to install the Ruby version.

In the <version> part, specify the version to install.

rvm install <version>

If the following is displayed, the installation is successful.

Here, 3.0 is specified.

rvm install 3.0

//===Abbreviation===

ruby-2.7.2 - #generating global wrappers.......
ruby-2.7.2 - #gemset created /home/ec2-user/.rvm/gems/ruby-2.7.0
ruby-2.7.2 - #importing gemsetfile /home/ec2-user/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.2 - #generating default wrappers.......

Let's specify the version to use with the following command.

rvm use <version>
rvm use 3.0.0

Finally, check that the version you specified earlier is displayed with the following command.

ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

This is the end of Ruby version change.

Install Bundler

After installing Ruby, then install ** Bundler **.

Ruby uses a library called ** Gem ** to manage packages.

You can easily install and uninstall with the Gem command, but if you use multiple Gem, a dependency will be created between the Gem and problems will occur due to different versions.

Therefore, Bundler accurately tracks and manages each version of Gem to provide a consistent environment for Ruby projects.

reference:

Now let's install Bundler. Enter the following command.

gem install bundler

Run the command to start the installation.

Check the version of Blundler installed.

Enter the following command:

bundler -v

After running the command, you should see something like this:

bundler -v
Bundler version 2.1.4

"Version 2.1.4" and version information are displayed.

You have now confirmed that Blendler is installed.

install yarn

Then install ** yarn **.

yarn is a package manager required to use JavaScript libraries.

There is also a package manager called npm that is compatible with yarn. However, Rails 6 requires yarn because Webpacker has become the standard.

Now let's install yarn.

Enter the following command:

npm i -g yarn

To see if yarn was actually installed, enter the following command:

yarn -v

When I run the command, I get the following:

yarn -v
1.22.10

Here, " 1.16.0 "is displayed. If the version information is displayed, you can confirm that yarn has been installed.

Check the version of Ruby on Rails

From here, we will check the version of Rails.

Check the Rails version by running the following command in Cloud9 Terminal.

rails -v

The Rails version specified by default is displayed as shown below.

rails -v
Rails 5.0.0

If you don't specify a version when you run rails new, your application will be created with this version.

Next, let's check the version of Rails installed.

Execute the following command.

gem list rails

The following will be displayed, so check the ** rails ** item. You can see that "5.0.0" is installed.

gem list rails

*** LOCAL GEMS ***

rails (5.0.0)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.3.0)
sprockets-rails (3.2.2)

Install Ruby on Rails

Finally, install Rails.

When installing Rails, you can specify the version as " -v version number ".

This time, install version " 6.1.1 ".

Reference: History of all versions of rails

Enter the following command:

gem install rails -v 6.1.1

Run the command to start the installation. It may take a few minutes to complete the installation.

After installing Rails, enter the following command to check your Rails version:

rails -v

When you run the command, you will see the following screen.

rails -v
Rails 6.1.1

" Rails 6.1.1 "is displayed.

This completes the installation of Ruby on Rails.

reference

-Ruby --Download -History of all versions of rails

Recommended Posts

Environment construction of Ruby on Rails from 0 [Cloud9] (From Ruby version change to Rails installation)
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
[Ruby on Rails] From MySQL construction to database change
Ruby on Rails --From environment construction to simple application development on WSL2
How to solve the local environment construction of Ruby on Rails (MAC)!
Deploy to Ruby on Rails Elastic beanstalk (Environment construction)
Ruby on Rails 6.0 environment construction memo
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
AWS Cloud9 environment construction Update Ruby to the latest stable version
Change from SQLite3 to PostgreSQL in a new Ruby on Rails project
How to link Rails6 Vue (from environment construction)
[Personal memo] Ruby on Rails environment construction (Windows)
[Error] Switch environment construction to use Ruby on Rails oss (open source)
Ruby on Rails development environment construction on M1 Mac
[Environment construction] Ruby on Rails 5.2 system development environment construction [within 1 hour]
Build a Ruby on Rails development environment on AWS Cloud9
Docker the development environment of Ruby on Rails project
[Ruby on Rails] How to change the column name
[Ruby on Rails] Change URL id to column name
[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)
Ruby on Rails environment construction using VirtualBox, Vagrant, cyberduck
Rails engineer environment construction ruby2.7.1
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
Deploy to Ruby on Rails Elastic beanstalk (IAM permission change)
<Dot installation> Introduction to Ruby on Rails5 Source code comparison
[Ruby on Rails] Elimination of Fat Controller-First, logic to model-
From Ruby on Rails error message display to Japanese localization
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
[Ruby On Rails] How to search and save the data of the parent table from the child table
Ruby environment construction summary ~ mac version ~
How to use Ruby on Rails
Rails on Docker environment construction procedure
[Environment construction] Uninstall rails from local
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
[Ruby on Rails] Change the save destination of gem refile * Note
From building to deploying Ruby on Jets in docker-compose environment <Part 2>
[Ruby on Rails] "|| =" ← Summary of how to use this assignment operator
Steps to build a Ruby on Rails development environment with Vagrant
Since I switched from Spring Boot (Java) to Ruby on Rails, I summarized my favorite points of Rails.
From pulling docker-image of rails to launching
[Ruby on Rails] Introduction of initial data
[Rails] Addition of Ruby On Rails comment function
[Ruby on Rails] How to use CarrierWave
Ruby on Rails installation method [Mac edition]
Let's summarize "MVC" of Ruby on Rails
part of the syntax of ruby ​​on rails
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Preparing to introduce jQuery to Ruby on Rails
[Ruby on Rails] Japanese notation of errors
[Ruby on Rails] How to use redirect_to
[Ruby on Rails] How to use kaminari
Explanation of Ruby on rails for beginners ①
[Ruby on rails] Implementation of like function
[Ruby on Rails] Button to return to top
CentOS8.2 (x86_64) + ruby2.5 + Rails5.2 + MariaDB (10.3.17) environment construction
How to build a Ruby on Rails environment using Docker (for Docker beginners)
How to build an environment for any version of Ruby using rbenv
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
[Ruby On Rails] How to search the contents of params using include?