前回のつづき。
開発環境
- Linux Mint 17.3 MATE 32bit
経緯
- はてなブログAPIで予約投稿したい
- OAuthなのでAccessToken取得する手続きが必要
- 2のためのRubyスクリプト発見
- ついでにはてなAPI用のRubyスクリプトもインストールしたいと思ったところで問題発生
Server Error
Server Error
http://ytyaru.hatenablog.com/entry/2017/05/14/000000
http://ytyaru.hatenablog.com/entry/2017/05/15/000000
http://ytyaru.hatenablog.com/entry/2017/05/16/000000
Ruby2.0が必要とわかった。複数バージョン管理するツールrbenvをインストールしようと試み中。
http://ytyaru.hatenablog.com/entry/2017/05/17/000000
.bash/
rbenvの設定に.bashrc
ファイルを設定する必要があるらしい。
しかし、そもそも.bash
ディレクトリが存在しなかったので、自分で作ってしまうことにした。
[[ -d ~/.rbenv ]] && \ export PATH=${HOME}/.rbenv/bin:${PATH} && \ eval "$(rbenv init -)"
ターミナルを再起動させてrbenv
を起動したが、前回と同じエラー。
$ 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
export
.bashrc
に記述したコードの意味を調べてみた。
export
は環境変数を作成するコマンドらしい。ディレクトリを作成してくれるわけではないらしい。
.rbenv/
/home/{user}/
ディレクトリ配下に.rbenv/
ディレクトリも作成した。
ターミナルを再起動させてrbenv
を起動した。エラーが出ない。OK。
$ rbenv rbenv 0.4.0 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をインストールする
sudo apt-get install rbenv
/home/{user}/
ディレクトリ配下に.rbenv/
ディレクトリを作成する/home/{user}/
ディレクトリ配下に.bash
ディレクトリを作成する/home/{user}/.bash
ディレクトリ配下に.bashrc
ファイルを作成する- 4のファイルに以下を記述する
[[ -d ~/.rbenv ]] && \ export PATH=${HOME}/.rbenv/bin:${PATH} && \ eval "$(rbenv init -)"
最後にターミナルを起動してrbenv
コマンドを実行する。エラーが出なければ成功。
課題
ruby-build
をインストールしてrbenv install
コマンドを使えるようにする。
所感
自分で作ってしまって大丈夫らしい。というか自分で作らないと動作しないのか。