jcabotc
Let’s say I have a module that is loaded, but not compiled into a beam file (it is defined in a exs file, or directly typed into iex). Is there any way to get the binary representation of that module at runtime?
I’ve tried with :code.get_object_code/1, but it only seems to work when there is a beam file, otherwise it returns :error:
iex(1)> defmodule Foo do
...(1)> end
{:module, Foo,
<<70, 79, 82, 49, 0, 0, 3, 32, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 117,
0, 0, 0, 12, 10, 69, 108, 105, 120, 105, 114, 46, 70, 111, 111, 8, 95, 95,
105, 110, 102, 111, 95, 95, 7, 99, 111, ...>>, nil}
iex(2)> :code.get_object_code(Foo)
:error
To be clear: what I’d like to get is the third element of the tuple returned by defmodule.
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
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
voughtdq
Why do you want to do that?
Maybe you want
Code.compile_file/2orCode.compile_string/2?jcabotc
My goal is to run code defined in my tests on a slave node to perform assertions about how a distributed application is behaving.
Code.compile_file/2andCode.compile_string/2return the module being defined in the file or the string, not the one that is already loaded, which is the one I’m looking for.michalmuskala
It’s not possible. You’d have to store the bytecode yourself.
tty
Are you writing tests in
.exsfiles ?Is your slave node started using
:slave? By using the proper path on startup or usingCode.append_path/1post startup the slave will load the module automatically for you.:rpcand execute the assertion code locally.jcabotc
I’d like to build it as a library, thus it should work with
.exand.exstests to provide the best user experience.Yes, I’m using
:slave, but I thinkCode.append_path/1won’t work because it receives a path where the.beamfiles are located, and there is no such path for.exsfiles.Yes, that is a viable solution. It doesn’t allow the user to run anonymous functions on the slave, which I think will provide the best experience, but I’ll probably end up doing something like that.