Homebrew で Git インストール

Homebrew で Git インストール

brew install git

~ $ brew install git
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
apm-bash-completion               fabric-completion                 rails-completion
aptly-completion                  gem-completion                    rake-completion
boom-completion                   grunt-completion                  ruby-completion
boot2docker-completion            homesick-completion               rustc-completion
brew-cask-completion              kitchen-completion                scipy
bundler-completion                launchctl-completion              sonar-completion
cap-completion                    maven-completion                  spring-completion
cargo-completion                  mix-completion                    stormssh-completion
django-completion                 numpy                             t-completion
docker-completion                 open-completion                   tmuxinator-completion
docker-compose-completion         packer-completion                 vagrant-completion
docker-machine-completion         pip-completion                    wpcli-completion
==> Updated Formulae
awscli                            nats-streaming-server             tor
harfbuzz                          qt5

==> Downloading https://homebrew.bintray.com/bottles/git-2.11.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.11.0.sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions

zsh functions have been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/git
==> Summary
🍺  /usr/local/Cellar/git/2.11.0: 1,452 files, 32.4M

インストールしたままだと、インストール前のGitとバージョンは変わらず

~ $ git --version
git version 2.10.1 (Apple Git-78)

bash_profile を再度読み込むと最新バージョンが適用される

source .bash_profile
~ $ git --version
git version 2.11.0

Ruby インストール(mac)

Ruby インストール(mac

Homebrewのインストール

Homebrew はインストールが済んでいる前提で説明します。 下記記事の Homebrew インストール説明部分を参照してください。 Javascript(Node.js) 開発環境の構築 - ifujimori’s blog

rbenv のインストール

brew install を使って rbenvをインストーする。

brew install rbenv ruby-build
~ $ brew install rbenv ruby-build
-bash: rew: command not found
~ $ brew install rbenv ruby-build
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
ammonite-repl            gitlab-ci-multi-runner   mcabber                  tin
apktool                  groonga                  pgformatter              vapoursynth
caddy                    influxdb                 prometheus               vim
collectd                 kapacitor                pushpin                  youtube-dl
dnscrypt-proxy           khal                     qbs
extract_url              libosmium                stormpath-cli
fzf                      link-grammar             telegraf

==> Installing dependencies for rbenv: autoconf, pkg-config, openssl, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Installing rbenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1_2.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.5K
==> Installing rbenv dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing rbenv dependency: ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20170112.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20170112
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20170112: 325 files, 174.5K, built in 6 seconds
==> Installing rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring rbenv-1.1.0.sierra.bottle.tar.gz
==> Caveats
Rbenv stores data under ~/.rbenv by default. If you absolutely need to
store everything under Homebrew's prefix, include this in your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion, run this and follow the instructions:
  rbenv init
==> Summary
🍺  /usr/local/Cellar/rbenv/1.1.0: 36 files, 63.2K

rbenv が正しくインストールできたか、バージョンを確認

~ $ rbenv -v
rbenv 1.1.0

インストール可能な ruby のバージョンの一覧を表示

rbenv install -l

バージョン 2.4.0 の ruby をインストール

rbenv install 2.4.0
~ $ rbenv install 2.4.0
ruby-build: use openssl from homebrew
Downloading ruby-2.4.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2
Installing ruby-2.4.0...
Installed ruby-2.4.0 to /Users/fujimori/.rbenv/versions/2.4.0

インストールされたことを rbenv versions で確認

~ $ rbenv versions
* system (set by /Users/fujimori/.rbenv/version)
  2.4.0

PATH に下記ディレクトリを追加する(.bash_profile にて追加)

/Users/[ユーザー名]/.rbenv/shims

rbenv global にて ruby をインストールしたバージョンに切り替える

rbenv global 2.4.0

ruby のバージョンの確認

~ $ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

Javascript(Node.js) 開発環境の構築

Javascript(Node.js) 開発環境の構築

Node.js のインストール mac

mac へのインストールについて

noode.js をインストールするにあたり、node.js のバージョン管理ツールの nodebrew をインストールして管理をしておくと、バージョンアップや複数バージョンの環境を自端末に残しておくと気に便利となります。 特にそういった要件がない方は、node.js のサイトにインストーラがありますので、それをインストールすれば動作環境は構築できます。

Node.js サイト 2016年1月 現在では、v7.4.0 が最新の安定版

https://nodejs.org/ja/

nodebrew を利用した Node.js のインストール

Homebrewのインストール、CommandlineTools のインストール、nodebrew のインストールの順に進めます。

Homebrew のインストール

下記URLを開きインストールコマンドをコピーする

http://brew.sh/index_ja.html

2016/1/24 時点の掲載コマンド

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

CommandlineTools も同時にインストールされるが、もしそこでエラーが出る場合は、CommandlineTools を先にインストールする。

CommandlineTools は下記URLからダウンロード可能

https://developer.apple.com/downloads/index.action

brew -v でバージョンを確認

~ $ brew -v
Homebrew 1.1.8
Homebrew/homebrew-core (git revision 3605; last commit 2017-01-23)

brew doctor で正常にインストールされているか確認

~ $ brew doctor
Your system is ready to brew.

Homebrew を利用してnodebrewをインストール

brew install nodebrew でインストールされる

~ $ brew install nodebrew
==> Using the sandbox
==> Downloading https://github.com/hokaccha/nodebrew/archive/v0.9.6.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v0.9.6
######################################################################## 100.0%
==> /usr/local/Cellar/nodebrew/0.9.6/bin/nodebrew setup_dirs
==> Caveats
Add path:
  export PATH=$HOME/.nodebrew/current/bin:$PATH

To use Homebrew's directories rather than ~/.nodebrew add to your profile:
  export NODEBREW_ROOT=/usr/local/var/nodebrew

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/nodebrew/0.9.6: 8 files, 38.0K, built in 8 seconds

nodebrew -v コマンドでバージョンの確認

~ $ nodebrew -v
nodebrew 0.9.6

nodebrew を利用して Node.js をインストール

nodebrew install-binary stable

下記のエラーとなった場合は、ディレクトリを作成する

Warning: Failed to create the file
Warning: /Users/fujimori/.nodebrew/src/v7.4.0/node-v7.4.0-darwin-x64.tar.gz:
Warning: No such file or directory

nodebrewが利用するディレクトリの作成

mkdir ~/.nodebrew
mkdir ~/.nodebrew/src
~ $ nodebrew install-binary stable
Fetching: https://nodejs.org/dist/v7.4.0/node-v7.4.0-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully
~ $ nodebrew ls
v7.4.0

PATH を通す(.bash_profileの追加)

export PATH=$HOME/.nodebrew/current/bin:$PATH

利用するバージョのを指定する

nodebrew use v7.4.0

v7.4.0 が利用可能になった

~ $ nodebrew ls
v7.4.0

current: v7.4.0