やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

LinuxMintにRuby2.xをインストールするためにrbenvをインストールした

前回のつづき。表題からしてまどろっこしいことになってきた。

開発環境

システムアップデート

LinuxMintのアップデートマネージャでアップデートした。今までやってなかった。

1時間40分を要した。

Ruby

https://www.ruby-lang.org/ja/downloads/

2017/02/23時点では2.4.0が最新の安定版らしい。

rbenv

rbenv で ruby の環境を整える - Qiita
rbenvとは?(rbenvを利用したRubyのインストール) - Qiita

rbenvという単語は前回までの調査でみたことがある。rbenv,RVMなどは異なるバージョンのRubyを共存させる環境なのだろう。

$ rbenv
プログラム 'rbenv' はまだインストールされていません。 次のように入力することでインストールできます:
sudo apt-get install rbenv

インストール

$ sudo apt-get install rbenv
[sudo] password for mint: 
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  rbenv
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 12 個。
22.0 kB のアーカイブを取得する必要があります。
この操作後に追加で 93.2 kB のディスク容量が消費されます。
取得:1 http://archive.ubuntu.com/ubuntu/ trusty/universe rbenv all 0.4.0+debian1-2 [22.0 kB]
22.0 kB を 0秒 で取得しました (29.8 kB/s)
以前に未選択のパッケージ rbenv を選択しています。
(データベースを読み込んでいます ... 現在 185445 個のファイルとディレクトリがインストールされています。)
.../rbenv_0.4.0+debian1-2_all.deb を展開する準備をしています ...
rbenv (0.4.0+debian1-2) を展開しています...
man-db (2.6.7.1-1ubuntu1) のトリガを処理しています ...
rbenv (0.4.0+debian1-2) を設定しています ...

.bashがない

/home/{user}/.bashディレクトリが存在しない。rcファイルに以下を追記すべきらしい。

[[ -d ~/.rbenv  ]] && \
  export PATH=${HOME}/.rbenv/bin:${PATH} && \
  eval "$(rbenv init -)"

linux - I don't see .bashrc file in my /home and /etc/skel direcories - Unix & Linux Stack Exchange
Google 翻訳

とりあえず飛ばす。

確認

$ rbenv
/usr/lib/rbenv/libexec/rbenv---version: 17 行: cd: /home/mint/.rbenv: そのようなファイルやディレクトリはありません

Usage: rbenv <command> [<args>]

Some useful rbenv commands are:
   commands    List all available rbenv commands
   local       Set or show the local application-specific Ruby version
   global      Set or show the global Ruby version
   shell       Set or show the shell-specific Ruby version
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List all Ruby versions available to rbenv
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
$ rbenv --version
/usr/lib/rbenv/libexec/rbenv---version: 17 行: cd: /home/mint/.rbenv: そのようなファイルやディレクトリはありません

なにこれおかしい。

$ rbenv install 2.4.0
rbenv: no such command `install'

参考URLどおりにできない。

$ rbenv commands
--version
commands
completions
exec
global
help
hooks
init
local
prefix
rehash
root
shell
shims
version
version-file
version-file-read
version-file-write
version-name
version-origin
versions
whence
which

所感

思った通りトラブル祭り。すぐに使えるものはないのか。

はてなAPIgemのためにRubyとgemが必要。 Ruby環境の使い分けのためにrbenvが必要。 rbenvのためにLinuxの常識が必要。 rbenvのためにLinuxの常識が必要。 パッケージ管理のためにツールが必要。ツールを使うために設定が必要。設定するためにLinuxの常識が必要。

などと。きっとgemのように管理しきれないナンヤカンヤで悩まされるのだろう。本筋からどんどん遠ざかっていく。