Rails6.0 ~ How to create an eco-friendly development environment

Achieve a clean development environment

I will leave a memorandum on how to create an environment construction for Ruby on Rails as eco-friendly as possible (without polluting the environment).

Please let me know if there is a way to make it cleaner!

How To

1. Create a suitable directory

mkdir sample-app && cd sample-app

2. bundle init

bundle init

3. Comment out rails in Gemfile

Gemfile



# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "rails"

4. Set the bundle

bundle config set path 'vendor/bundle'
gem install bundler

5. bundle install rails

bundle install

6. Create a rails application with rails new

bundle exec rails new . -B -d mysql --skip-test

You can specify the database with -d, so change it accordingly.

When creating the API

bundle exec rails new . -B -d mysql --skip-test --api

Let's put it in API mode with --api.

Then the Gemfile conflicts with the one originally created in init, but press Y to Overwrite.

7. Bundle install again based on the Gemfile created by rails new

bundle install
bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"

See also: https://qiita.com/fukuda_fu/items/463a39406ce713396403

8. install webpacker

bundle exec rails webpacker:install

9. Create DB

bundle exec rails db:create
  1. Yay! You’re on Rails!

スクリーンショット 2020-10-04 14.29.38.png

Impressions

Well, I feel that using Docker does not pollute the environment first ... I feel like I'm told How Dare You! Not using Docker, but I hope it will be helpful when building an environment locally without using Docker ~

Recommended Posts

Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to build an environment with Docker
How to create an application
How to build Rails, Postgres, ElasticSearch development environment with Docker
[rails] How to create a partial template
How to build Rails 6 environment with Docker
[Rails] How to execute "rails db: create" etc. in production environment EC2
How to install Pry after building Rails development environment with Docker
How to write Rails
[Rails] How to create a graph using lazy_high_charts
How to link Rails6 Vue (from environment construction)
How to uninstall Rails
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
How to create docker-compose
How to easily create a pull-down in Rails
[Rails] How to create a Twitter share button
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
[Rails] Create an application
[Rails] How to use PostgreSQL in Vagrant environment
How to create an oleore certificate (SSL certificate, self-signed certificate)
How to create a Java environment in just 3 seconds
[Rails] How to create a signed URL for CloudFront
How to push an app developed with Rails to Github
How to make an almost static page with rails
How to build Java development environment with VS Code
(Ruby on Rails6) How to create models and tables
[Rails] How to display an image in the view
Rails6 development environment construction [Mac]
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
How to handle an instance
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to create a method
[Rails] How to use Scope
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
[Rails] How to delete production environment MySQL data after putting it in the development environment
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
How to set environment variables when using Payjp with Rails
I tried to create a java8 development environment with Chocolatey
Create an AWS IoT EduKit development environment with Ubuntu 20.04 + VirtualBox 6.1
How to create an application server on an EC2 instance on AWS
What happened in "Java 8 to Java 11" and how to build an environment
How to set and describe environment variables using Rails zsh
I tried to create a padrino development environment with Docker
How to create an environment that uses Docker (WSL2) and Vagrant (VirtualBox) together on Windows
[Rails] How to use gem "devise"