Techioz Blog

アプリケーションを実行しようとすると Ruby で URI エラーが発生する [終了]

概要

Windows 10 で新しいアプリケーションを作成しようとすると、何らかの理由で Ruby でこのエラーが発生します。

rails aborted!
URI::InvalidURIError: bad URI(is not URI?): C:\\Ruby\\bin;C:\\sqlite;
C:/Users/Lies/demo42/Rakefile:6:in `<main>' <internal:C:/Ruby/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
\<internal:C:/Ruby/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb\>:38:in `require' bin/rails:4:in `\<main\>'
(See full trace by running task with --trace)
rails  turbo:install stimulus:install
rails aborted!
URI::InvalidURIError: bad URI(is not URI?): C:\\Ruby\\bin;C:\\sqlite;
C:/Users/Lies/demo42/Rakefile:6:in `<main>' <internal:C:/Ruby/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
\<internal:C:/Ruby/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb\>:38:in `require' bin/rails:4:in `\<main\>'
(See full trace by running task with --trace)

Google であらゆる場所を検索し、これまでのところ、パス変数を C に変更して再インストールを 2 回試みました。uby を作成し、パスと DATABASE 変数に追加します。

私の Ruby、Rails は最新バージョンです。

これまでのところ、アプリケーションの作成に役立つのは「rails new demo –minimal」の実行だけですが、サーバーを実行しようとすると、次のメッセージが表示されます: localhost:3000 出力

誰かがこれに遭遇し、修正方法を見つけましたか?私は教授に尋ねましたが、それは教授の脳も理解しようとしていたのです。

データベース.yml

# SQLite. Versions 3.8.0 and up are supported. 
# gem install sqlite3 
# Ensure the SQLite 3 gem is defined in your Gemfile 
# gem "sqlite3" 
#
default: &default 
  adapter: sqlite3 
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 
  timeout: 5000
development: 
  <<: *default 
  database: db/development.sqlite3 
# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
  <<: *default 
  database: db/test.sqlite3 
production: 
  <<: *default 
  database: db/production.sqlite3

編集:将来の読者のために: これは、「C:」と「C:in」の 2 つの値を持つ DATABASE_URL_ 環境変数です。 後で再び問題に遭遇しましたが、「Path」環境変数を編集して Ruby と git 値のみを含むようにすることで、なんとか再度修正できました。

解決策

DATABASE_URL 環境変数があるため、Rails はそれを優先データベース構成として使用し、解析しようとします。しかし、その値は無効です。それがエラーが発生する理由です

この代わりに、config/database.yml を使用してデータベース設定を保存し、DATABASE_URL 環境変数を削除します。

続きを読む