henriquesati
** (ArgumentError) unknown registry: Req.Finch on a simple http request using Req library
I’m doing a POST request using Req but i’m getting the error ** (ArgumentError) unknown registry: Req.Finch. I found the same problem on elixir reddit but I couldnt manage to understand and apply the possible solution
My code:
defmodule GetPayloadInfo do
def doReq do
token = "XXX"
req = Req.Request.new(method: :post, url: "https://sandbox.asaas.com/api/v3/pix/qrCodes/decode")
req = Req.Request.put_headers(req, [{"accept", "application/json"}, {"acess_token", token}, {"content-type", "application/json"} ])
{req, resp} = Req.Request.run_request(req)
end
end
Then I simply call the function on my main file with a simple hello world output so make sure its all fine before this
Hello.say_hi()
GetPayloadInfo.doReq()
and this is my mix.exs file
defmodule TestesPay.MixProject do
use Mix.Project
def project do
[
app: :testes_pay,
version: "0.1.0",
elixir: "~> 1.16",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
telemetry: [enabled: false],
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:req, "~> 0.5.0"}
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
]
end
end
the code contains no scripts, only .ex files, located at lib
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 10 Posts
henriquesati
the full compilation error in case it helps
wojtekmach
Oh, you’re using Req at compile-time, i.e. in module body and similar. In that case it seems you need to explicitly start dependencies:
henriquesati
Thanks for you help, it worked.
Applicationits a built in module in elixir/mix andensure_all_started allis another module (or method, I don’t know how things are exactly referenced in lixir) that ensures all dependencies a module uses are loaded before the module itself?I dont quite get the ''using req at compile-time", there is another way os using it?
wojtekmach
compile-time vs runtime is a pretty broad topic so to just scratch the surface when you have a module:
the first IO.puts is executed while the module is being compiled. When it is being used at runtime, that IO.puts will not be executed. On the other hand, the second IO.puts is NOT executed when the module is being compiled. It is only executed when you call Foo.foo(). Doing things at compile-time is definitely an Elixir super power and for this particular use case you need that Application.ensure_all_started. (The reason is Req library starts a supervision tree in its application callback module. If it didn’t, ensure_all_started would not be necessary.) In vast majority of day to day Elixir programming, you don’t need ensure_all_started, it is done for you.
dimitarvp
No, not at all. Modules are loaded just fine but there is the concept of applications that start various OTP processes which is achieved by the applications themselves being “started” (“application” being a useful abstraction here).
jswanner
Are you sure you want to be using Req at compile time? I suspect you want to move your use of Req into a function so that you can use it while your application is running
henriquesati
what do you mean by that? I have no idea what i’m doing to be real, i’m learning elixir and the lib now, the docs aren’t helping much, i’m stuck in pretty basic things
BrightEyesDavid
What does your “main file” look like?
Others will correct me if I’m wrong, but I think, based on @wojtekmach’s answer, it’s because your function calls are not themselves in a function, so they call functions at compile time instead of run time:
Try putting those function calls in a function:
Then (without the
Application.ensure_all_started), run theMain.gofunction in iex (in the directory containing your Mix project):wojtekmach
I think we have a winner: Tweak Finch supervisor children strartup order by elfenlaid · Pull Request #289 · sneako/finch · GitHub
LorenzoD
For those finding this thread after running into this error when using
Reqin a function within aMix.Taskmodule: This problem is resolved by adding@requirements ["app.start"]at the module level. This ensures thatReqand its dependencies are available for use when you execute the Mix task.More information can be found in the documentation here.