---
title: "RVMでrubyをインストールしたのにrubyが認識されない | C#もぐもぐ"
description: "C#をもぐもぐしているblog"
url: "https://blog.223n.tech/posts/89/"
---

# RVMでrubyをインストールしたのにrubyが認識されない

2018年7月28日

[Ruby](https://blog.223n.tech/tags/Ruby/) [トラブル対応](https://blog.223n.tech/tags/%E3%83%88%E3%83%A9%E3%83%96%E3%83%AB%E5%AF%BE%E5%BF%9C/) [RVM](https://blog.223n.tech/tags/RVM/)

RVMを[公式サイトのやりかた](https://rvm.io/rvm/install)を見ながらインストールしたのですが、
なぜかrubyを動かそうとすると、そんなコマンドはないと言われました。

今回は、この対応メモです。

```bash
223n@ja223n:~$ ruby -v
bash: ruby: コマンドが見つかりません
```

- PC: DELL Inspiron 14
- OS: Debian 9 (stretch) 64bit

```bash
223n@ja223n:~$ rvm install ruby-head
Warning, new version of rvm available '1.29.4', you are using older version '1.29.3'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
Checking requirements for debian.
Requirements installation successful.
Installing Ruby from source to: /home/tatami/.rvm/rubies/ruby-head, this may take a while depending on your cpu(s)...
Cloning from https://github.com/ruby/ruby.git, this may take a while depending on your connection. 
HEAD is now at 297ae3437e mjit.c: clean up unit link from iseq
From https://github.com/ruby/ruby
* branch trunk -> FETCH_HEAD
Already up-to-date.
git checkout trunk
Copying from repo to src path...
ruby-head - #autoreconf.
ruby-head - #configuring.................................................|
ruby-head - #post-configuration..
ruby-head - #compiling...................................................-
ruby-head - #installing...............
ruby-head - #making binaries executable..
Installed rubygems 3.0.0.beta1 is newer than ignore provided with installed ruby, skipping installation, use --force to force installation.
ruby-head - #gemset created /home/tatami/.rvm/gems/ruby-head@global
ruby-head - #importing gemset /home/tatami/.rvm/gemsets/global.gems.......
ruby-head - #generating global wrappers........
ruby-head - #gemset created /home/tatami/.rvm/gems/ruby-head
ruby-head - #importing gemsetfile /home/tatami/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-head - #generating default wrappers........
ruby-head - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-head - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri
```

さらに、Useコマンドを実行したところ、なにやらおかしなことを言われます。

```bash
223n@ja223n:~$ rvm use ruby-head
RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
```

確かに、`/bin/bash --login`を実行すると、rubyは正しく動くようです。

参照関連が正しく設定されていないと思い調べたところ、こちらの記事を見つけました。

[RVM 経由で Ruby を入れるときにハマったこと / tsujimotterのノートブック](http://tsujimotter.hatenablog.com/entry/2014/06/20/193710)

記事にもあるとおり、以下のコマンドを実行する必要があったみたいです。

```bash
source ~/.rvm/scripts/rvm
```

今回は、`~/.bashrc`の最後に上のコマンドを追加して、正常に動くことを確認しました。

[記事一覧に戻る](https://blog.223n.tech/posts/)
