ianrumford
Hello all. I’d appreciate some input on this.
To explain consider these two modules ModuleA and ModuleB
defmodule ModuleA do
@doc "ModuleA fun1"
def fun1(x) do
x
end
end
defmodule ModuleB do
require ModuleA
:functions |> ModuleA.__info__ |> IO.inspect
ModuleA |> Code.get_docs(:all) |> IO.inspect
end
If both modules are being compiled together, the get_docs in ModuleB returns nil. Only if ModuleA has been compiled previously does the get_docs in ModuleB succeed.
The crux of my question is how do I wait during the compilation of ModuleB for the beam file for ModuleA to exist?
Thanks in advance.
btw I’m using 1.6.3
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bbense
First the modules need to be in separate files. There is an ensure_compiled function that you can use in ModuleB to be sure that ModuleA is available.
ianrumford
Hi.
Thanks for taking the time to respond.
The example modules were/are in separate files.
Re
ensure_compiled/1andensure_loaded, I had already tried them and they do not guarantee the beam file exists, just that the module is loaded/compiled so that e.g. theModuleA.__info__call works.bbense
Yes, you’re right. I missed that part. compiled != BEAM file in path.
It’s pretty straightforward to check that the BEAM file for the module is in the load_path, but I’m not sure how you’d force a compile if it is not.
:code.where_is_file('Elixir.ModuleA.beam')ianrumford
Hi,
Sorry I didn’t want to go “full monte” in the original post and clutter up my question.
I have already tried to find the beam file (using
:code.which(ModuleA)) and although I get a path back, the path does not exists.I’ve even tried (horror!) sleeping in
ModuleBfor a really (really!) long time but still can’t get the path / docs.There is something about the way the ParallelCompiler works I don’t understand. Even though its code suggests
ModuleA'sbeam file is written before theModuleB'sdependency is fulfilled (thecompiledmessage is sent back to its compiler process), the beam file still seems to be not available.Really appreciate your time helping on this.
bbense
I don’t have time to dig into this right now, but one thing to keep in mind is that one way to think of Elixir is that it’s a scripting language for running a compiler. You can put valid Elixir code outside the module def and that code will run at compile time. Something awful like
I doubt that will work, but something like that is the solution.
ianrumford
Hi,
Your time is appreciated
I’d already tried sleeping inside the
defmodulebut not outside. (Since the parallel compile works with files not modules, and there is only one module in the file, the inside/outside distinction is moot in this case?).But I tried outside: I put a
Process.sleep(:infinity)outside thedefmoduleinModuleB, touched both.exfiles and did amix compile. As you’d expect themixjust hung.While the
mixwas hanging, I had a look atebinand looked for the beam file forModuleAwhich was surely compiled by then. There was no file.It suggests that the parallelcompiler only writes the
beamfiles late in the compilation, after (all?) the spawned compiler processes have completed.Which begs the question as to the use case for
Code.get_docsi.e. when can you use it?