ecto_sqlite3 icon indicating copy to clipboard operation
ecto_sqlite3 copied to clipboard

Elixir Plugin for Jetbrains cannot debug projects with ecto-sqlite3

Open jdmarshall opened this issue 9 months ago • 23 comments

Do you guys have any advice I could offer the maintainer on what this error means? Or is there anything on your end that could be done?

[error] :gen_statem #PID<0.7560.0> terminating ** (ErlangError) Erlang error: :not_loaded :erlang.nif_error(:not_loaded) (exqlite 0.29.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2 (exqlite 0.29.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2 Queue: [internal: {:connect, :init}] Postponed: [] State: Exqlite.Connection Callback mode: :handle_event_function, state_enter: false [error] :gen_statem #PID<0.7563.0> terminating ** (ErlangError) Erlang error: :not_loaded :erlang.nif_error(:not_loaded) (exqlite 0.29.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2 (exqlite 0.29.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2

This repeats about half a dozen times and then the debugger exits after:

[notice] Application would exited: Would.Application.start(:normal, []) returned an error: shutdown: failed to start child: Ecto.Migrator ** (EXIT) exited in: DBConnection.Holder.checkout(#PID<0.7554.0>, [log: #Function<13.15884367/1 in Ecto.Adapters.SQL.with_log/3>, timeout: :infinity, log: false, schema_migration: true, ecto_query: :schema_migration, telemetry_options: [schema_migration: true], pool: DBConnection.ConnectionPool, repo: Would.Repo, timeout: 15000, pool_size: 5]) ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

This is on Elixir 1.18.2 (compiled with Erlang/OTP 26)

jdmarshall avatar Mar 14 '25 20:03 jdmarshall

You mentioned it here as well https://github.com/elixir-sqlite/exqlite/issues/320. Just linking these together so there's a trail.

I honestly don't know. Is there a repository we can check out or where this is able to be recreated reliably?

warmwaffles avatar Mar 15 '25 03:03 warmwaffles

That one disappeared off my radar and I had quite forgotten that I'd already filed it.

And it does seem more likely to be on that side...

I'm reasonably sure a blank phx.gen project will trigger this. I'll confirm that and post my findings over there.

jdmarshall avatar Mar 16 '25 04:03 jdmarshall

@jdmarshall what OS is this running on?

warmwaffles avatar Mar 17 '25 01:03 warmwaffles

Oh, I didn’t say.

macOS Sonoma

And Webstorm if that matters.

jdmarshall avatar Mar 17 '25 19:03 jdmarshall

@jdmarshall can you chuck config :exqlite, force_build: true into either your config.exs or dev.exs and mix deps.compile --force exqlite. I want to see if this is because of a precompiled binary issue not loading properly.

You'll need to make sure you have make and a C compiler installed. gcc/clang just need to make sure it is available to $CC

warmwaffles avatar Mar 17 '25 20:03 warmwaffles

After restarting webstorm, same error.

Things that work:

# CLI
mkdir huh
cd huh
mix archive.install hex phx_new
mix phx.new .  --database sqlite3
mix test
Finished in 0.00 seconds (0.00s async, 0.00s sync)
5 tests, 0 failures

# Webstorm, debug
5 tests, 0 failures

Things that don't work:

https://hexdocs.pm/ecto/getting-started.html

Followed the instructions down to https://hexdocs.pm/ecto/getting-started.html#creating-the-schema

At this point I now get the error.

And in case I missed some subtle step or order of operations:

https://github.com/jdmarshall/ecto_issues

jdmarshall avatar Mar 19 '25 22:03 jdmarshall

I've never messed with webstorm, but your ecto_issues project compiles and runs just fine from the command line.

Running ExUnit with seed: 882902, max_cases: 48

..
Finished in 0.00 seconds (0.00s async, 0.00s sync)
1 doctest, 1 test, 0 failures

Does webstorm build and run from the _build/ dir and read deps from the deps/ dir?

warmwaffles avatar Mar 20 '25 01:03 warmwaffles

Yeah it runs from the CLI which is why it’s a problem between the plugin and the libraries.

I believe it does use the _build directory, but I think this is the error:

{:error, {:upgrade, ~c"Upgrade not supported by this NIF library."}}

jdmarshall avatar Apr 27 '25 15:04 jdmarshall

Yea this library doesn't implement upgrade callback. However, I don't think there is necessarily harm in simply no-op'ing it.

warmwaffles avatar Apr 28 '25 02:04 warmwaffles

Yes please.

jdmarshall avatar Apr 28 '25 18:04 jdmarshall

I got a ping on a related issue today. Did this ever get fixed?

jdmarshall avatar Jul 23 '25 03:07 jdmarshall

I have not.

warmwaffles avatar Jul 23 '25 12:07 warmwaffles

What do you suppose the odds are that a complete NIF noob can file a PR for this without setting the world on fire?

jdmarshall avatar Jul 23 '25 17:07 jdmarshall

I can do it, I just forgot to do it. I'll swing through and fix it since I need to update the sqlite version anyways.

warmwaffles avatar Jul 23 '25 18:07 warmwaffles

Implemented a no-op here https://github.com/elixir-sqlite/exqlite/commit/780b8abae39ffe650968b58d68233609bd116be2

@jdmarshall give v0.33.0 a shot and report back.

warmwaffles avatar Jul 24 '25 03:07 warmwaffles

Getting

11:08:49.109 [warning] The on_load function for module Elixir.Autumn.Native returned:
{:error, {:upgrade, ~c"Upgrade not supported by this NIF library."}}

Which is some other library having this same problem, not exqlite. So... improvement?

But the errors still complain about eqlite:

11:17:12.631 [error] :gen_statem #PID<0.31599.0> terminating
** (ErlangError) Erlang error: :not_loaded
    :erlang.nif_error(:not_loaded)
    (exqlite 0.33.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2
    (exqlite 0.33.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2
Queue: [internal: {:connect, :init}]
Postponed: []
State: Exqlite.Connection
Callback mode: :handle_event_function, state_enter: false

11:17:12.631 [error] :gen_statem #PID<0.31600.0> terminating
** (ErlangError) Erlang error: :not_loaded
    :erlang.nif_error(:not_loaded)
    (exqlite 0.33.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2
    (exqlite 0.33.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2
Queue: [internal: {:connect, :init}]
Postponed: []
State: Exqlite.Connection
Callback mode: :handle_event_function, state_enter: false

11:17:12.632 [error] :gen_statem #PID<0.31604.0> terminating
** (ErlangError) Erlang error: :not_loaded
    :erlang.nif_error(:not_loaded)
    (exqlite 0.33.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2
    (exqlite 0.33.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2
Queue: [internal: {:connect, :init}]
Postponed: []
State: Exqlite.Connection
Callback mode: :handle_event_function, state_enter: false

11:17:12.632 [error] :gen_statem #PID<0.31606.0> terminating
** (ErlangError) Erlang error: :not_loaded
    :erlang.nif_error(:not_loaded)
    (exqlite 0.33.0) Elixir.Exqlite.Sqlite3NIF.erl:21: Exqlite.Sqlite3NIF.open/2
    (exqlite 0.33.0) Elixir.Exqlite.Connection.erl:540: Exqlite.Connection.do_connect/2
Queue: [internal: {:connect, :init}]
Postponed: []
State: Exqlite.Connection
Callback mode: :handle_event_function, state_enter: false

I wonder if the plugin needs to be doing something different instead.

jdmarshall avatar Jul 24 '25 18:07 jdmarshall

See also https://github.com/KronicDeth/intellij-elixir/issues/989

jdmarshall avatar Jul 24 '25 18:07 jdmarshall

If you'd like me to pump some debugging messages into my config to get a better error, let me know.

jdmarshall avatar Jul 24 '25 18:07 jdmarshall

I don't know honestly. I don't use Intellij with elixir so I have no idea.

warmwaffles avatar Jul 24 '25 18:07 warmwaffles

Hey guys I just happened to run into this problem over the last 2 days and it looks like the changes that went out in v0.33 fixed it.

@jdmarshall you just need to add Exqlite.Sqlite3NIF in the interpreted modules filter as attaching to NIFs is not supported by the debugger.

Image

Kovak avatar Jul 25 '25 23:07 Kovak

It works!

Now how to document this for posterity?

jdmarshall avatar Jul 26 '25 02:07 jdmarshall

So is this resolved?

warmwaffles avatar Jul 30 '25 20:07 warmwaffles

A workaround is a start not an end. An end would be documentation.

All I can say is that it's no longer crashing. LiveView pages never finish loading in the debugger, and no breakpoints hit. So I still am flying blind.

jdmarshall avatar Jul 30 '25 20:07 jdmarshall