0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Homebrewを用いずにruby,rbenvの環境を構築する

Posted at

概要

この記事ではHomebrewでrubyの環境構築を意地でも使いたくない私の備忘録です。

実行環境

チップ  Apple M1
OS   Sequoia
シェル  BASH

初めに

whichコマンドを用いて、rbenvがインストールされているか確認。

$which rbenv
/Users/.rbenv/bin/rbenv

pathが出力されればインストールされている

gitでrbenv,ruby-buildを取得

場所は~/.rbenvとしてホームディレクトリ直下に不可視ファイルとして配置し、移動する。

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd .rbenv

ディレクトリの中身を確認したい場合は以下のコマンドで確認

ls 
open .

pluginsディレクトリに移動してruby-buildをクローンする。
ruby-buildはrbenvのプラグインで、rbenv installはこのプラグインがないと使用できません

cd plugins
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

rubyを取得する

--listオプションでダウンロード可能なバージョンを調べる

rbenv install —list
rbenv install 取得したいrubyのversion

これで完成です。

⚠️libyamlでエラーが出力される場合

rbenvは依存関係をYAMLで管理するため外部ライブラリが必要です。
先ほどと同じようにgitで取得する方法を以下に示します。
makeとcmakeを使用します。
⚠️ビルドに時間がかかります

git clone https://github.com/yaml/libyaml.git
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
make
sudo make install

⚠️cmakeがない場合

libyamlをビルドするにあたってcmakeが必要になります。

git clone https://github.com/Kitware/CMake.git

whichコマンドでpathを取得し
⚠️標準出力は異なる場合があります

$ which cmake
/usr/local/bin/cmake

標準入力で使えるようにシェル(Bash)に記述

$cd
$open .bash_profile
bash_profile
### Cmake ###
export PATH=/usr/local/bin/Cmake:$PATH

変更内容をシェルに読み込ませて、cmakeにpathが通ったか確認します。

$source ~/.bash_profile
$cmake --version
/usr/local/bin/cmake

まとめ

Homebrewを使わない場合、依存ライブラリを自力でダウンロードして手動で設定する必要があり、非常に手間です。大人しくHomebrewを使用したほうがいいのでしょうか...

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?