elixir-sqlite/ecto_sqlite3

Elixir Plugin for Jetbrains cannot debug projects with ecto-sqlite3

Opened this issue · 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)

You mentioned it here as well elixir-sqlite/exqlite#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?

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 what OS is this running on?

Oh, I didn’t say.

macOS Sonoma

And Webstorm if that matters.

@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

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

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?

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."}}

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

Yes please.

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

I have not.

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

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.

Implemented a no-op here elixir-sqlite/exqlite@780b8ab

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

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.

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

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

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

It works!

Now how to document this for posterity?

So is this resolved?

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.