### 背景/現状

Ruby 3.1.2 と Rails 7.0.4 を用いて、ローカルに開発環境を構築したい

#### 環境

M1チップ  
Big Sur ver 11.2.3  
Ruby 3.1.2

### やりたいこと

Rails 7.0.4 をインストールしたい

### 実際に出てるエラーメッセージ

`gem install rails -v 7.0.4` 実行時

```

    cannot load such file -- psych (LoadError)
    
```

### 既に試したこと

rbenvアンインストール後、再度インストールし実行

### 他におかしいと思うこと

・`rails -v` 実行時、"zsh: command not found: rails" が出ずに以下が出る

```

    rails -v
    rbenv: rails: command not found
    
    The `rails' command exists in these Ruby versions:
      2.7.6
    
```

・`bundle install` 実行時

"Could not locate Gemfile" と表示される

■iterms画面（文字列貼り付け）

```

    hirokinagai@HirokinoMBP ~ % gem list
    <internal:/Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- psych (LoadError)
        from <internal:/Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems.rb:609:in `load_yaml'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/config_file.rb:346:in `load_file'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/config_file.rb:189:in `initialize'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:73:in `new'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:73:in `do_configuration'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:38:in `run'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/bin/gem:21:in `<main>'
    hirokinagai@HirokinoMBP ~ % gem install rails -v 7.0.4
    <internal:/Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- psych (LoadError)
        from <internal:/Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems.rb:609:in `load_yaml'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/config_file.rb:346:in `load_file'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/config_file.rb:189:in `initialize'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:73:in `new'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:73:in `do_configuration'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/gem_runner.rb:38:in `run'
        from /Users/hirokinagai/.rbenv/versions/3.1.2/bin/gem:21:in `<main>'
    hirokinagai@HirokinoMBP ~ % ruby -v
    ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
    hirokinagai@HirokinoMBP ~ % rails -v
    rbenv: rails: command not found
    
    The `rails' command exists in these Ruby versions:
      2.7.6
    
    hirokinagai@HirokinoMBP ~ % which ruby
    /Users/hirokinagai/.rbenv/shims/ruby
    hirokinagai@HirokinoMBP ~ % which rails
    /Users/hirokinagai/.rbenv/shims/rails
    hirokinagai@HirokinoMBP ~ % which gem
    /Users/hirokinagai/.rbenv/shims/gem
    hirokinagai@HirokinoMBP ~ % bundle install
    Could not locate Gemfile
    hirokinagai@HirokinoMBP ~ % bundle update
    Could not locate Gemfile
    hirokinagai@HirokinoMBP ~ %
    
```

■参考画像

[![画像の説明をここに入力](https://i.stack.imgur.com/qFgQm.jpg)](https://i.stack.imgur.com/qFgQm.jpg)
CC BY-SA 4.0
2022-09-16T09:07:19.070
91135
2023-07-24T02:01:25.133
2022-09-16T12:42:47.087
3060
45480
question
ruby-on-rails
Rails 7.0.4 のインストールができない (エラー：cannot load such file -- psych (LoadError))
> bundle install 実行時  
>  "Could not locate Gemfile" と表示される

そもそもプロジェクトの準備ができていないのでは？  
プロジェクトフォルダ内にGemfileを用意してから、フォルダ内にrailsをインストールしてください。
CC BY-SA 4.0
2022-09-17T01:33:43.537
91140
2022-09-17T01:33:43.537
43005
91135
answer