I wish to use Ecto for a project but when I realize the command mix ecto.create I have the following error Invalid Elixir version requirement in mix.exs file. However, I have the same version in this file as that at present used. I tried with of other one versions but the error is always present. Can you help me?
Can you please provide the exact output of the
mix ecto.create run? Also the content of your
mix.exs might help us.
Hy NobbZ, thanks for your answer.
This is the exact output :
And this is the Mix.exs file :
Dont use sudo!
root will probably see a different version of elixir than
theo does in his current environment.
Why do You need sudo to run mix ecto.create?
Running with sudo change your identity, it changes also asdf setup because it is on a per user setup I think.
You could try to really check this.
$ sudo asdf current elixir
asdf is installed “per user”, so I assume that
root won’t even see the
asdf script/function (however its implemented).
PS: Please do not post screenshots of code or your shell, use proper copy and paste to get the content in the post and then use either 4 spaces indentation per line or wrap it into triple backticks (```) to mark the code block as such as you are used to it from your favorite markdown dialect.
This makes reading and especially copying them a lot easier (and uses less bandwith of my mobile dataplan).
Oh, and you will probably need to
sudo rm -rf _build deps before using
sudo again to “repair” ownerships and permissions.
Thanks guy, you were right it was a problem at sudo. However, I have another error at the same stage and I do not know what to do.
Error message :
(Mix) The database for Farmbot.Repo couldn’t be created: an exception was raised:
** (RuntimeError) Connect raised a KeyError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.
(elixir) lib/keyword.ex:377: Keyword.fetch!/2 (postgrex) lib/postgrex/protocol.ex:610: Postgrex.Protocol.auth_md5/4 (postgrex) lib/postgrex/protocol.ex:504: Postgrex.Protocol.handshake/2 (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2 (connection) lib/connection.ex:622: Connection.enter_connect/5 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Have you an idea of what can I do ?
You should check your credentials. It is located in the config folder of your farmbot application.
You should match that the user specified is allowed to use database.
In case not… You might look at https://www.postgresql.org/docs/9.5/static/sql-createuser.html
I’m using ecto with mariadb (Mariaex) in a non-Phoenix app. This is my database config:
# config/config.exs config :iocp_monitor, ecto_repos: [IocpMonitor.Repo] config :iocp_monitor, IocpMonitor.Repo, database: "iocp", username: "root", password: "1q2w3e4r5t", hostname: "localhost", port: "3306", migration_timestamps: [type: :utc_datetime]
And this is my repo definition:
defmodule IocpMonitor.Repo do use Ecto.Repo, otp_app: :iocp_monitor, adapter: Ecto.Adapters.MySQL end
When I run
mix ecto.create and
mix ecto.migrate, they finished successfully, and I can see the new database and the new tables in it, so I suppose the database connection configuration is correct. But when I try to start my otp app, this happens:
13:22:08.399 [error] GenServer #PID<0.421.0> terminating ** (RuntimeError) connect raised ArgumentError exception.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 if you wish to see all of the details :erlang.byte_size/1 (mariaex) lib/mariaex/messages.ex:103: Mariaex.Messages.encode_handshake_resp/1 (mariaex) lib/mariaex/messages.ex:219: Mariaex.Messages.encode/2 (mariaex) lib/mariaex/protocol.ex:1156: Mariaex.Protocol.msg_send/3 (mariaex) lib/mariaex/protocol.ex:218: Mariaex.Protocol.handle_handshake/3 (mariaex) lib/mariaex/protocol.ex:171: Mariaex.Protocol.handshake_recv/2 (db_connection) lib/db_connection/connection.ex:66: DBConnection.Connection.connect/2 (connection) lib/connection.ex:622: Connection.enter_connect/5 Last message: nil State: Mariaex.Protocol
I have no idea why it fails, and I don’t know where to add the configuration
:show_sensitive_data_on_connection_error. Can anyone help? Thanks in advance.
I have the same problem, I don’t have idea where to put
config :my_app, MyApp.Repo, # Help diagnose connection errors: show_sensitive_data_on_connection_error: true