mbklein

mbklein

Using Ecto.Query in a RemoteExecutionCell

I’ve got Livebook (using the livebook:edge Docker container) set up and properly executing code on a remote node (though I have some configuration questions that I’ll address in a different topic). The only major problem I’m having comes when I try to use Ecto.Query.

If I try to import Ecto.Query, I get an error that says error: module Ecto.Query is not loaded and could not be found.

If I try to use Ecto.Query.from(...) directly without importing it, I get

** (ErlangError) Erlang error: {:exception, :undef, [{Ecto.Query, :from, [Meadow.Data.Schemas.Work, [limit: 1]], []}, {:elixir_eval, :__FILE__, 1, [file: ~c"#cell:gsynocyaqcunidcyirskfy2tyhh2wirn", line: 5]}, {:elixir, :"-eval_external_handler/1-fun-2-", 4, [file: ~c"src/elixir.erl", line: 376]}, {:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 750]}, {:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1026]}, {:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 456]}]}
    (kernel 9.0.2) erpc.erl:702: :erpc.call/5
    #cell:gsynocyaqcunidcyirskfy2tyhh2wirn:4: (file)

If I try to require it before using it that way, I get the ...is not loaded and could not be found error again.

Oddly, remote autocomplete finds it just fine:

Other macros (like Logger.warning/2) seem to work just fine, so it doesn’t seem to be a macro issue.

Can anyone provide any guidance or answers on this?

Marked As Solved

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @mbklein as a basic question, did you Mix.install ecto as a dependency? Can you show the failing livebook?

Also Liked

mbklein

mbklein

Yup, adding ecto as a dependency of the local notebook got it working.

It’s so easy to lose track of what’s building which AST and passing it off to where in an RPC situation, but it makes sense that macros need to be evaluated before the remote call is made.

Last Post!

mbklein

mbklein

Yup, adding ecto as a dependency of the local notebook got it working.

It’s so easy to lose track of what’s building which AST and passing it off to where in an RPC situation, but it makes sense that macros need to be evaluated before the remote call is made.

Where Next?

Popular in Questions Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement