【備忘録】cloud9にrbenvを導入。

##結論：実行したコマンド

```
$ rvm version
$ rvm seppuku
$ rvm -v
$ grep rvm ~/.bashrc
$ grep rvm ~/.bash_profile
$ grep rvm ~/.profile
$ grep rvm ~/.zshrc
$ vim ~/.bash_profile
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ cd ~/.rbenv && src/configure && make -C src
$ rbenv -v
$ rbenv init
$ source ~/.bash_profile
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ rbenv install -list
```


```ruby

#{username}:~/environment $ rvm version
rvm 1.29.8 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
#{username}:~/environment $ rvm seppuku
Are you SURE you wish for rvm to implode?
This will recursively remove /home/ec2-user/.rvm and other rvm traces?
(anything other than 'yes' will cancel) > yes
Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudo rvm-shell and rvm-auto-ruby)
Removing rvm wrappers in /home/ec2-user/.rvm/bin
Hai! Removing /home/ec2-user/.rvm
/home/ec2-user/.rvm has been removed.

Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still.
Please check all .bashrc .bash_profile .profile and .zshrc for RVM source lines and delete or comment out if this was a Per-User installation.
Also make sure to remove `rvm` group if this was a system installation.
Finally it might help to relogin / restart if you want to have fresh environment (like for installing RVM again).


#{username}:~/environment $ rvm -v
cat: /home/ec2-user/.rvm/VERSION: No such file or directory
bash: /home/ec2-user/.rvm/scripts/base: No such file or directory
cat: /home/ec2-user/.rvm/VERSION: No such file or directory
rvm  () by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
#{username}:~/environment $ grep rvm ~/.bashrc
rvm_silence_path_mismatch_check_flag=1 # prevent rvm complaints that nvm is first in PATH
#{username}:~/environment $ grep rvm ~/.bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#{username}:~/environment $ grep rvm ~/.profile
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#{username}:~/environment $ grep rvm ~/.zshrc
export PATH="$PATH:$HOME/.rvm/bin"
#{username}:~/environment $ vim ~/.bash_profile
```

```:.bash_profile
#export PATH="$PATH:$HOME/.rvm/bin"
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
```

```ruby
#{username}:~/environment $ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Cloning into '/home/ec2-user/.rbenv'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 2878 (delta 3), reused 2 (delta 0), pack-reused 2868
Receiving objects: 100% (2878/2878), 562.74 KiB | 10.23 MiB/s, done.
Resolving deltas: 100% (1795/1795), done.

#{username}:~/environment $ cd ~/.rbenv && src/configure && make -C src
bash: /home/ec2-user/.rvm/scripts/initialize: No such file or directory
bash: /home/ec2-user/.rvm/scripts/hook: No such file or directory
make: Entering directory `/home/ec2-user/.rbenv/src'
gcc -fPIC     -c -o realpath.o realpath.c
gcc -shared -Wl,-soname,../libexec/rbenv-realpath.dylib  -o ../libexec/rbenv-realpath.dylib realpath.o 
make: Leaving directory `/home/ec2-user/.rbenv/src'
#{username}:~/.rbenv (master) $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
＃新しいターミナルに移動

#{username}:~/environment $ rbenv -v
rbenv 1.1.2-40-g62d7798
#{username}:~/environment $ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"
```

>~/.bash_profile:にeval "$(rbenv init -)"を追加

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/313771/6fe0c502-71e7-41e1-8c1e-0e9b3cb56d9c.png)

```ruby

#{username}:~/environment $ source ~/.bash_profile
function
#{username}:~/environment $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/ec2-user/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: not found
Unless you plan to add Ruby versions manually, you should install ruby-build.
Please refer to https://github.com/rbenv/ruby-build#installation

Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/home/ec2-user/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

```

`Checking `rbenv install' support: not found`
※この場合はruby-buildが必要なため、下記のコマンドを実行。

```

#{username}:~/environment $ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/home/ec2-user/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 11325 (delta 4), reused 11 (delta 3), pack-reused 11307
Receiving objects: 100% (11325/11325), 2.40 MiB | 19.51 MiB/s, done.
Resolving deltas: 100% (7498/7498), done.
#{username}:~/environment $ rbenv install -list
2.5.8
2.6.6
2.7.2
3.0.0
jruby-9.2.14.0
mruby-2.1.2
rbx-5.0
truffleruby-21.0.0
truffleruby+graalvm-21.0.0

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
#{username}:~/environment $ ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
```

```ruby

$ gem install rails
$ rails -v
#error
#bundle installをするよう指示される
$ bundle install
$ rails -v
#Rails 5.2.3
```



```ruby
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

Post-install message from by_star:
Upgrading ByStar
----------------

* Chronic gem (used for time string parsing) has been removed as a hard dependency for ByStar,
however it is still supported. If you would like to use Chronic with ByStar, please explicitly
include `gem chronic` into your Gemfile.
Post-install message from rails_best_practices:
********************************************************************************

  rails_best_practices is a code metric tool to check the quality of rails codes.

  I highly recommend you browse the Rails Best Practices website first.

      http://rails-bestpractices.com

  Enjoy!

      Richard Huang (flyerhzm@gmail.com)

********************************************************************************
#{username}:~/environment/samantha (miyagaki2) $ 
```


> Railsアプリのconfig.i18n.fallbacks = trueを確認し,
I18n (>= 1.1.0) と Rails (< 5.2.2.2) を使用している場合は
'config.i18n.fallbacks = [I18n.default_locale]'とする。
そうでない場合、フォールバックはI18n 1.1.xでアプリ内で壊れるらしい




参考にした記事（いつもありがとうございます。）
---
- [config.i18n.fallbacksのメッセージについて](https://qiita.com/tsurugeek/items/e1292536aa8b67962490)
- [rbenvでruby3.0.0をインストールする](https://qiita.com/m_masashi/items/e4ecefebfc5eff4a7619)