Building a Ruby environment for classes on Mac

!macOS-11.1!ruby-2.7.2p137

Preface (Introduction)

To take a class called multi-scale simulation special course, we will build an environment with macbook Air (2019) provided by the laboratory.

While I was writing, M1 Mac became a hot topic and Ruby was upgraded to 3.0.0, but unfortunately this article does not support them.

Homebrew

Install the mac package manager.

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

Check if the installation was successful

> brew docotor
-> Your system is ready to brew.

Git & GitHub

First, install Git.

> brew install git

The version of Git is

> git --version
-> git version 2.29.2

fish

The default shell is zsh, but I would like to use fish instead.

> brew install fish

The version of fish is

> fish -v
->fish, version 3.1.2

Fisher

There is Fisher as a plugin management tool for fish. There is also oh-my-fish, but I chose Fisher because of its ease of management (settings can be changed with GUI).

> curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish

Fisher version

> fisher -v
-> fisher, version 4.1.0

from zsh to fish

Change the default shell to fish.

> sudo nano /etc/shells

Changed as follows

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
#Add PATH as below
/usr/local/bin/fish⏎ 

Also with a command

> chsh -s /usr/local/bin/fish

Install plugin with Fisher

Insert a plugin that allows you to easily display and search command input with C-r.

First, install fzf completion

> brew install fzf

After that, insert the plugin with Fisher.

> fisher add jethrokuan/fzf

That's it.

Ruby

Mac already has Ruby.

> which ruby
-> /usr/bin/ruby

However, I want to use the latest version (v2.7.2 at the time of writing) using the version control tool rbenv of Ruby, so I put rbenv.

> brew install rbenv

The version of rbenv is

> rbenv -v
-> rbenv 1.1.2

However, the environment variables have not changed because they have not been set.

> echo $PATH
-> /usr/local/bin /usr/bin /bin /usr/sbin /sbin

So, create a fish config file and

> cd ~/.config/fish
> nano config.fish

Add the following.

set -x PATH $HOME/.rbenv/shims $PATH

Then reboot and check if the path passed

> which ruby
-> /Users/[User name]/.rbenv/shims/ruby

> which gem
-> /Users/[User name]/.rbenv/shims/gem
> echo $PATH
-> /Users/hisanagaken/.rbenv/shims /usr/local/bin /usr/bin /bin /usr/sbin /sbin

Install the specified version of Ruby

Check the current version of Ruby

> rbenv version
-> * system (set by /User/[User name]/.rbenv/version)

Enter the version of Ruby you want to include.

> rbenv install 2.7.2

For the time being, this is the end.

Reference material

IOS app engineer's mac environment construction memo

Recommended Posts

Building a Ruby environment for classes on Mac
[Ruby] Building a Ruby development environment on Ubuntu
[For beginners] Until building a Web application development environment using Java on Mac OS
Build a Java development environment on Mac
Build a JMeter environment on your Mac
Create a development environment for Ruby 3.0.0 and Rails 6.1.0 on Ubuntu 20.04.1 LTS
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Building a development environment for Flutter on Win10 --- Flutter SDK Install (2020 preservation version)
[Ruby on Rails] Let's build an environment on mac
Ruby on Rails development environment construction on M1 Mac
Create a Java development environment using jenv on Mac
Build a Ruby on Rails development environment on AWS Cloud9
[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)
Ruby Learning # 11 Building a Calculator
Ruby Learning # 32 Building a Quiz
Ruby ① Build a Windows environment
Learn the meaning of "passing the PATH" by building a Java development environment on Mac
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
A story about speeding up unittest on Docker for Mac
Build a CentOS 8 virtual environment on your Mac with VirtualBox
Explanation of Ruby on rails for beginners ③ ~ Creating a database ~
Ruby Learning # 19 Building a Better Calculator
Ruby environment construction summary ~ mac version ~
Ruby Learning # 22 Building a Guessing Game
Ruby on Rails 6.0 environment construction memo
Build Java development environment (for Mac)
Build a XAMPP environment on Ubuntu
[Java & SpringBoot] Environment Construction for Mac
Install Java development environment on Mac
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
From building to deploying Ruby on Jets in docker-compose environment <Part 2>
I tried to create a Spring MVC development environment on Mac
From building to deploying Ruby on Jets in docker-compose environment <Part 1>
Prepare a transcendentally simple PHP & Apache environment on Mac with Docker
Build a development environment where Ruby on Rails breakpoints work on Windows
Building a haskell environment with Docker + VS Code on Windows 10 Home
Steps to build a Ruby on Rails development environment with Vagrant
Building a Deep Learning environment (Ubuntu 20.04 LTS)
Let's install Docker on Windows 10 and create a verification environment for CentOS 8!
Building a DLNA server on Ubuntu (just move for the time being)
Spring Boot environment construction memo on mac
Building a Lambda development environment in Eclipse
Java development environment construction memo on Mac
[Ruby on Rails] About bundler (for beginners)
Building a Kotlin development environment using SDKMAN
Minimal steps to set up a Ruby environment with rbenv on Ubuntu 20.04
[Ruby on Rails] Create a pie chart for each column with Chartkick
Creating a java web application development environment with docker for mac part1
Technical platform for building a mail-order site
Try building a GPU container on GCP.
Ruby Learning # 12 Building a Mad Libs Game
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Instructions for building Apache Derby on Windows
How to solve the local environment construction of Ruby on Rails (MAC)!
Explanation of Ruby on rails for beginners ①
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Create a java web application development environment with docker for mac part2
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Building an environment for WordPress, MySQL and phpMyAdmin with Docker Compose on EC2
A memorandum when building an environment with Ruby3.0 x Rails6.1 x Docker x CentOS Stream