fireproofsocks
How can you run a .exs file from another .exs file? My inspiration comes from the basic config.exs file which runs another .exs via import_config "#{Mix.env()}.exs". I’d like to do the same type of thing, but not with just config files.
Would something like Mix.Tasks.Run.run(["path/to/my.exs"]) work in an umbrella? How does Mix know which directory is the base directory?
Thanks for any pointers!
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
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
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
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
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
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 9 of 9 Posts
josevalim
easco
According to the source,
import_configcalls__import__which eventually leads to a call toCode.eval_file. elixir/lib/mix/lib/mix/config.ex at a444533db118aebb7bbeadff7b9b9985059309f8 · elixir-lang/elixir · GitHubfireproofsocks
This works in a single app:
Code.require_file("priv/repo/#{Mix.env()}.exs")But when that is inside an umbrella, it doesn’t work, presumably because the path would need to be something like
Code.require_file("apps/app_one/priv/repo/#{Mix.env()}.exs")josevalim
Use Application.app_dir to build the path within a certain app.
joaoevangelista
You can use
Application.app_dir/2to fetch the file that lies inside the application folder like that:The second argument will join the parts of the path and return a String
fireproofsocks
Application.app_dirseems to work fine from the root of the umbrella, but that seems to be where my code breaks when I try to run it during a Docker deployment.The error I get is this:
ericmj
You can’t call mix functions at runtime because they are not available in your release. You need to evaluate
Mix.env()at compile time, module attributes can help you do that:fireproofsocks
Brilliant, thank you! I had guessed that may have been the problem and I tried using
System.get_env("MIX_ENV")– that worked too. Not every docker image involved here has Mix in it..c4710n
Code.eval_file/2works, too.