Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RuntimeError) connect raised KeyError exception: key :password not found #122

Closed
axelrindle opened this issue Oct 1, 2019 · 4 comments
Closed

Comments

@axelrindle
Copy link
Contributor

When running mix ecto.setup, the following exception raises:

10:33:22.366 [error] GenServer #PID<0.287.0> terminating
** (RuntimeError) connect raised KeyError exception: key :password not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
    (elixir) lib/keyword.ex:393: Keyword.fetch!/2
    (postgrex) lib/postgrex/protocol.ex:722: Postgrex.Protocol.auth_md5/4
    (postgrex) lib/postgrex/protocol.ex:579: Postgrex.Protocol.handshake/2
    (db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Accent.Repo couldn't be created: killed

This is my .env file:

DATABASE_URL=postgres://postgres:supersecretpassword@localhost:5432/accent

The database accent exists and the user postgres has access to it. Tested that with the psql tool.

Some version information:

accent: git checkout v1.3.0

Erlang/OTP 21 [erts-10.2] [source] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.9.1 (compiled with Erlang/OTP 21)

psql (PostgreSQL) 9.6.13

libyaml-0-2:armhf                     0.1.7-2
libyaml-dev:armhf                     0.1.7-2
@remi
Copy link
Member

remi commented Oct 1, 2019

Hi @axelrindle,

What do you use to feed the environment configuration in .env to mix commands? Are you using nv like mentioned in the README.md?

@axelrindle
Copy link
Contributor Author

@remiprev No, i'm just sourcing the file.

@remi
Copy link
Member

remi commented Oct 1, 2019

If you’re soucing the file, you have to prefix each environment variable with export because otherwise they will be treated as local variables.

> cat .env
FOO=bar

> source .env
> echo $FOO
> cat .env
export FOO=bar

> source .env
> echo $FOO
bar

@axelrindle
Copy link
Contributor Author

@remiprev Oh, my bad 😅 Using export did the trick, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants