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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #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
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










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.