WSLっていうかUbuntuだと思います。
結論からいうと
- libsqlite3-dev
- libffi-dev
を入れておきましょう。
libsqlite3-dev
gem install rails -v 7.0.0.alpha2
してrails new
すると次のエラーがでます。
An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
libsqlite3-devを入れてあげます。
sudo apt install libsqlite3-dev
libffi-dev
続いてrails c
すると次のエラーがでます。
ledsun@MSI:~/t/seven-eleven[1]►bin/rails console 0.334s (main|●?) 10:36 /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- fiddle (LoadError) from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/reline-0.2.7/lib/reline/terminfo.rb:1:in `<main>' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/reline-0.2.7/lib/reline.rb:10:in `<main>' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/irb-1.3.7/lib/irb.rb:13:in `<main>' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/commands/console/console_command.rb:3:in `<main>' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command/behavior.rb:44:in `block (2 levels) in lookup' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command/behavior.rb:40:in `each' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command/behavior.rb:40:in `block in lookup' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command/behavior.rb:39:in `each' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command/behavior.rb:39:in `lookup' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command.rb:73:in `find_by_namespace' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/command.rb:46:in `invoke' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/railties-7.0.0.alpha2/lib/rails/commands.rb:18:in `<main>' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/ledsun/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from bin/rails:4:in `<main>'
Rubyにlibffisdevelが認識されていないようです。 libffi-devを入れてRubyをビルドし直します。
sudo apt install -y libffi-dev rbenv install 3.1.0-preview1