"rails new sample"を実行した後、"rails s"でアプリケーションサーバPuma起動 → エラー
PS C:\Users\孝憲\sample> rails s
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/path.rb:101:in `start_with?': incompatible character encodings: UTF-8 and Windows-31J (Encoding::CompatibilityError)
エンコーディングがおかしいらしい
該当箇所で、"force_encoding('UTF-8')"してみた →とりあえずサーバ起動した
- コード
C:\Ruby24-x64\lib\ruby\gems\2.4.0\gems\bootsnap-1.3.1\lib\bootsnap\load_path_cache
path.rb
path.rb
def stability
@stability ||= begin
#if Gem.path.detect { |p| expanded_path.start_with?(p.to_s) } ←修正前
if Gem.path.detect { |p| expanded_path.start_with?(p.to_s.force_encoding('UTF-8')) }
STABLE
elsif Bootsnap.bundler? && expanded_path.start_with?(Bundler.bundle_path.to_s)
STABLE
elsif expanded_path.start_with?(RUBY_LIBDIR) && !expanded_path.start_with?(RUBY_SITEDIR)
STABLE
else
VOLATILE
end
end
end
これでとりあえず起動
PS C:\Users\孝憲\sample> rails s
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.12.0 (ruby 2.4.4-p296), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
でも localhost:3000 にアクセスするとエラー →未解決
2018-08-30 22:27:59 +0900: Rack app error handling request { GET / }
#<ArgumentError: invalid multibyte character>
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/backtrace_cleaner.rb:29:in `add_gem_filters'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/backtrace_cleaner.rb:20:in `initialize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails.rb:54:in `new'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails.rb:54:in `backtrace_cleaner'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:257:in `env_config'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/engine.rb:694:in `build_request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:592:in `build_request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/engine.rb:523:in `call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'