前提・実現したいこと
[前提]
速習実践ガイドでRuby on Railsを勉強しています。
"bin/rails s"をdevelopment環境で行ったときにブラウザ上で"fe_sendauth: no password supplied"というエラーが発生します。
昨日はこのようなエラーはでなくて今日突然development環境でエラーが発生しました。
昨日production環境用のデータベースやproduction環境用のユーザを作成したことが影響しているかもしれません。昨日はそのあとでもdevelopment環境でエラーがでなかったのですが。。
[実現したいこと]
エラーを改善してdevelopment環境で開発したい。
[開発環境]
・ubuntu20.04
・ruby2.5.1
・rails 5.2.4.4
・postgresql 12.4
発生している問題・エラーメッセージ
ubuntu
1boko@DESKTOP-FS4FC62:~/Code/taskleaf2$ bin/rails s 2=> Booting Puma 3=> Rails 5.2.4.4 application starting in development 4=> Run `rails server -h` for more startup options 5Puma starting in single mode... 6* Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas 7* Min threads: 5, max threads: 5 8* Environment: development 9* Listening on tcp://localhost:3000 10Use Ctrl-C to stop 11Started GET "/" for ::1 at 2020-09-14 17:05:53 +0900 12 13PG::ConnectionBad (fe_sendauth: no password supplied 14):
該当のソースコード
↓"database.yml"です。"."の入力方向が分かりませんでした。
databaseyml
1# PostgreSQL. Versions 9.1 and up are supported. 2# 3# Install the pg driver: 4# gem install pg 5# On OS X with Homebrew: 6# gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7# On OS X with MacPorts: 8# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9# On Windows: 10# gem install pg 11# Choose the win32 build. 12# Install PostgreSQL and put its /bin directory on your path. 13# 14# Configure Using Gemfile 15# gem 'pg' 16# 17default: &default 18 adapter: postgresql 19 encoding: unicode 20 # For details on connection pooling, see Rails configuration guide 21 # http://guides.rubyonrails.org/configuring.html#database-pooling 22 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 24development: 25 <<: *default 26 database: taskleaf2_development 27 28 # The specified database role being used to connect to postgres. 29 # To create additional roles in postgres see `$ createuser --help`. 30 # When left blank, postgres will use the default role. This is 31 # the same name as the operating system user that initialized the database. 32 #username: taskleaf2 33 34 # The password associated with the postgres role (username). 35 #password: 36 37 # Connect on a TCP socket. Omitted by default since the client uses a 38 # domain socket that doesn't need configuration. Windows does not have 39 # domain sockets, so uncomment these lines. 40 #host: localhost 41 42 # The TCP port the server listens on. Defaults to 5432. 43 # If your server runs on a different port number, change accordingly. 44 #port: 5432 45 46 # Schema search path. The server defaults to $user,public 47 #schema_search_path: myapp,sharedapp,public 48 49 # Minimum log levels, in increasing order: 50 # debug5, debug4, debug3, debug2, debug1, 51 # log, notice, warning, error, fatal, and panic 52 # Defaults to warning. 53 #min_messages: notice 54 55# Warning: The database defined as "test" will be erased and 56# re-generated from your development database when you run "rake". 57# Do not set this db to the same as development or production. 58test: 59 <<: *default 60 database: taskleaf2_test 61 62# As with config/secrets.yml, you never want to store sensitive information, 63# like your database password, in your source code. If your source code is 64# ever seen by anyone, they now have access to your database. 65# 66# Instead, provide the password as a unix environment variable when you boot 67# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68# for a full rundown on how to provide these environment variables in a 69# production deployment. 70# 71# On Heroku and other platform providers, you may have a full connection URL 72# available as an environment variable. For example: 73# 74# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75# 76# You can use this database configuration with: 77# 78# production: 79# url: <%= ENV['DATABASE_URL'] %> 80# 81production: 82 <<: *default 83 database: taskleaf2_production 84 username: taskleaf2 85 password: <%= ENV['TASKLEAF2_DATABASE_PASSWORD'] %> 86
↓"pg_hba.conf"です。
conf
1# Database administrative login by Unix domain socket 2local all postgres peer 3 4# TYPE DATABASE USER ADDRESS METHOD 5 6# "local" is for Unix domain socket connections only 7local all all md5 8# IPv4 local connections: 9host all all 127.0.0.1/32 md5 10# IPv6 local connections: 11host all all ::1/128 md5 12# Allow replication connections from localhost, by a user with the 13# replication privilege. 14local replication all peer 15host replication all 127.0.0.1/32 md5 16host replication all ::1/128 md5
試したこと
"database.yml"のdevelopment環境の欄に以下のようにパスワードをセットしてみたところ
databaseyml
1~~~ 2development: 3 <<: *default 4 database: taskleaf2_development 5 username: taskleaf2 6 password: <%= ENV['TASKLEAF2_DATABASE_PASSWORD'] %> 7~~~
以下のような異なるエラーが発生しました。なので上記の変更は取り消しました。
ubuntu
1boko@DESKTOP-FS4FC62:~/Code/taskleaf2$ bin/rails s 2=> Booting Puma 3=> Rails 5.2.4.4 application starting in development 4=> Run `rails server -h` for more startup options 5Puma starting in single mode... 6* Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas 7* Min threads: 5, max threads: 5 8* Environment: development 9* Listening on tcp://localhost:3000 10Use Ctrl-C to stop 11Started GET "/" for ::1 at 2020-09-14 17:21:30 +0900 12 (2.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 13 ↳ /home/boko/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/log_subscriber.rb:98 14 15ActiveRecord::StatementInvalid (PG::InsufficientPrivilege: ERROR: permission denied for table schema_migrations 16: SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC):
補足情報(FW/ツールのバージョンなど)
今まで特にdevelopment環境においてパスワードで弾かれたことはなかったのに、development環境で弾かれるようになりました。development環境で弾かれることはあるのでしょうか?
どのような些細なことでも回答やコメントしていただけると嬉しいです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。