Add dotenv-rails gem to fix environment variable error for db setup #334

Merged
kiliczsh merged 3 commits from fix/db-setup-env-var-error into main 2024-02-07 09:32:19 +08:00
kiliczsh commented 2024-02-07 04:06:31 +08:00 (Migrated from github.com)

Environment variables were not read by db setup command.

rails db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:create
connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied
Couldn't create 'maybe_development' database. Please check your configuration.
bin/rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished)

@Shpigford

Environment variables were not read by db setup command. ```bash rails db:setup --trace ** Invoke db:setup (first_time) ** Invoke db:create (first_time) ** Invoke db:load_config (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:load_config ** Execute db:create connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied Couldn't create 'maybe_development' database. Please check your configuration. bin/rails aborted! ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished) ``` @Shpigford
pmareke commented 2024-02-07 04:23:54 +08:00 (Migrated from github.com)

Environment variables were not read by db setup command.

rails db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:create
connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied
Couldn't create 'maybe_development' database. Please check your configuration.
bin/rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished)

@Shpigford

I've just reported this error, thanks so much!

> Environment variables were not read by db setup command. > > ```shell > rails db:setup --trace > ** Invoke db:setup (first_time) > ** Invoke db:create (first_time) > ** Invoke db:load_config (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:load_config > ** Execute db:create > connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied > Couldn't create 'maybe_development' database. Please check your configuration. > bin/rails aborted! > ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished) > ``` > > @Shpigford I've just reported this error, thanks so much!
kiliczsh commented 2024-02-07 04:25:15 +08:00 (Migrated from github.com)

Environment variables were not read by db setup command.

rails db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:create
connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied
Couldn't create 'maybe_development' database. Please check your configuration.
bin/rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished)

@Shpigford

I've just reported this error, thanks so much!

Resolves #335

> > Environment variables were not read by db setup command. > > ```shell > > rails db:setup --trace > > ** Invoke db:setup (first_time) > > ** Invoke db:create (first_time) > > ** Invoke db:load_config (first_time) > > ** Invoke environment (first_time) > > ** Execute environment > > ** Execute db:load_config > > ** Execute db:create > > connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied > > Couldn't create 'maybe_development' database. Please check your configuration. > > bin/rails aborted! > > ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: fe_sendauth: no password supplied (ActiveRecord::ConnectionNotEstablished) > > ``` > > > > > > > > > > > > > > > > > > > > > > > > @Shpigford > > I've just reported this error, thanks so much! Resolves #335
pmareke (Migrated from github.com) reviewed 2024-02-07 04:43:55 +08:00
pmareke (Migrated from github.com) left a comment

Thanks so much for the PR!

Thanks so much for the PR!
@@ -16,0 +16,4 @@
# Database Configuration
DB_HOST=localhost
POSTGRES_PASSWORD=postgres
pmareke (Migrated from github.com) commented 2024-02-07 04:43:41 +08:00

Should we add in the README the default values in the .env?

Should we add in the README the default values in the .env?
kiliczsh (Migrated from github.com) reviewed 2024-02-07 04:45:06 +08:00
@@ -16,0 +16,4 @@
# Database Configuration
DB_HOST=localhost
POSTGRES_PASSWORD=postgres
kiliczsh (Migrated from github.com) commented 2024-02-07 04:45:06 +08:00

@pmareke it would be better if we add default values to .env.example

@pmareke it would be better if we add default values to .env.example
pmareke (Migrated from github.com) reviewed 2024-02-07 04:46:42 +08:00
@@ -16,0 +16,4 @@
# Database Configuration
DB_HOST=localhost
POSTGRES_PASSWORD=postgres
pmareke (Migrated from github.com) commented 2024-02-07 04:46:42 +08:00

Love it too yes.

Love it too yes.
lorenzopalaia commented 2024-02-07 04:48:01 +08:00 (Migrated from github.com)

Pointed out this issue on Discord earlier. I can confirm that this fixes it.

Pointed out this issue on Discord earlier. I can confirm that this fixes it.
kiliczsh (Migrated from github.com) reviewed 2024-02-07 04:48:49 +08:00
@@ -16,0 +16,4 @@
# Database Configuration
DB_HOST=localhost
POSTGRES_PASSWORD=postgres
kiliczsh (Migrated from github.com) commented 2024-02-07 04:48:48 +08:00

🚀

✅ 🚀
Sign in to join this conversation.