James_E
I have a mix app, and the following snippet in runtime.exs:
if config_env() == :prod do
# ...
phx_ip = case System.get_env("PHX_IP", "ANY") do
"ANY" -> :any
s -> case MyApp.Util.parse_ip(s) do
{:ok, ip} -> ip
{:error, error} -> :erlang.error(error)
end
end
However, when I try to port this snippet to dev.exs (we need to test the specific-IP handling code in dev), it won’t compile because MyApp.Util isn’t available.
How should I make a module of my code available to dev.exs?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
garrison
This is not an answer to your question, but it’s perfectly fine to gate code by env in
runtime.exs; this is in fact exactly what theif config_env() == :prod doline in your snippet does.(You are probably aware of this, but I mention it just in case.)
seeplusplus
This may be similar to this thread,
But based on some quick testing I’d say you don’t really want to do what you’re doing inside a
dev.exs. It’s only run before compile (which is why you can’t read your modules’ functions) and is not run after you’ve built your release. In your case it looks like you’re reading an env var to determine which IPs to bind to, which is definitely something you’d want to do on each startup.Could you just remove the
if config_env() == :prodaround yourphx_ipcode to test in dev?adamu
Any code that needs to be tested should be in a module, not in a config file.
hauleth
You cannot use functions defined in your code in
dev.exsas there you define compile-time config. So you will have chicken-egg problem if that would be possible.