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
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
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
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.
IOS app engineer's mac environment construction memo
Recommended Posts