ccstorch

ccstorch

Unable to user postgrex in a mix task: "unknown registry: Postgrex.TypeManager"

Hi!

I have a project that is only a collection of mix tasks, there is no ecto, phoenix, supervisor, nothing.
I tried to setup the postgrex library but I’m not finding a way to make it work.

It works fine if I run this code on iex -S mix:

{:ok, pid} = Postgrex.start_link(hostname: "localhost", username: "postgres", password: "postgres", database: "test_tb", show_sensitive_data_on_connection_error: true)
Postgrex.query!(pid, "SELECT id, name FROM company LIMIT 10", [])

But the same code on a mix task, I’m receiving this error:

16:14:37.725 [error] GenServer #PID<0.214.0> terminating
** (ArgumentError) unknown registry: Postgrex.TypeManager
    (elixir 1.11.4) lib/registry.ex:1276: Registry.key_info!/1
    (elixir 1.11.4) lib/registry.ex:569: Registry.lookup/2
    (postgrex 0.15.10) lib/postgrex/type_supervisor.ex:23: Postgrex.TypeSupervisor.locate/2
    (postgrex 0.15.10) lib/postgrex/protocol.ex:914: Postgrex.Protocol.bootstrap/3
    (postgrex 0.15.10) lib/postgrex/protocol.ex:635: Postgrex.Protocol.handshake/2
    (postgrex 0.15.10) lib/postgrex/protocol.ex:155: Postgrex.Protocol.connect_endpoints/6
    (db_connection 2.4.0) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
Last message: nil
State: Postgrex.Protocol

My mix.env:

{:mongodb, "~> 0.5.1"},
{:postgrex, ">= 0.15.0"}

And I’m using elixir 1.11.4 and erlang/OTP 23

If anyone could help me, it would be great.

Marked As Solved

ccstorch

ccstorch

Got help from the postgrex repo. It was missing this line before using the lib:

Application.ensure_all_started(:postgrex)

Where Next?

Popular in Questions Top

jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement