jonas

jonas

Compatability of exqlite/Sqlite3, Escript and WSL2?

Hi,
I developed a small program that uses ecto + ecto_sqlite3 and as a nested dependency exqlite.
The program works fine when I execute it with mix run, but when I try to compile it to an escript fails to run.

It crashes right at the startup with the following warning + error messages:

13:22:19.172 [warn]  The on_load function for module Elixir.Exqlite.Sqlite3NIF returned:
{:function_clause,
 [
   {:filename, :join, [{:error, :bad_name}, 'sqlite3_nif'],
    [file: 'filename.erl', line: 454]},
   {Exqlite.Sqlite3NIF, :load_nifs, 0,
    [file: 'lib/exqlite/sqlite3_nif.ex', line: 14]},
   {:code_server, :"-handle_on_load/5-fun-0-", 1,
    [file: 'code_server.erl', ...]}
 ]}


13:22:19.211 [debug] Websocket connection up on worker #PID<0.231.0>

13:22:19.169 [error] Process #PID<0.296.0> raised an exception
** (FunctionClauseError) no function clause matching in :filename.join/2
    (stdlib 3.15.1) filename.erl:454: :filename.join({:error, :bad_name}, 'sqlite3_nif')
    (exqlite 0.6.1) lib/exqlite/sqlite3_nif.ex:14: Exqlite.Sqlite3NIF.load_nifs/0
    (kernel 8.0.1) code_server.erl:1317: anonymous fn/1 in :code_server.handle_on_load/5

13:22:19.204 [error] GenServer #PID<0.286.0> terminating
** (RuntimeError) connect raised UndefinedFunctionError exception. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
    (exqlite 0.6.1) Exqlite.Sqlite3NIF.open/1
    (exqlite 0.6.1) lib/exqlite/connection.ex:402: Exqlite.Connection.do_connect/2
    (db_connection 2.4.0) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.15.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Exqlite.Connection

It ‘may’ be relate to a warning that is logged during compilation of the exqlite dependency:

In file included from /usr/include/string.h:494:0,
                 from sqlite3/sqlite3.c:14232:
In function ‘memcpy’,
    inlined from ‘rbuGetUpdateStmt.constprop’ at sqlite3/sqlite3.c:201606:5,
    inlined from ‘rbuStep’ at sqlite3/sqlite3.c:202418:7,
    inlined from ‘sqlite3rbu_step’ at sqlite3/sqlite3.c:202651:24:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: ‘__builtin_memcpy’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Has anyone ever encountered similar problems with exqlite?

Since it works fine when it’s executed with mix run, might it be related to some incompatibility related to WSL2? Or could it be another reason entirely?

Thanks in advance.

Most Liked

kevinlang

kevinlang

Hey,

The root error is:

    (stdlib 3.15.1) filename.erl:454: :filename.join({:error, :bad_name}, 'sqlite3_nif')
    (exqlite 0.6.1) lib/exqlite/sqlite3_nif.ex:14: Exqlite.Sqlite3NIF.load_nifs/0

Which comes from the line of code where we load our NIF:

  def load_nifs() do
    path = :filename.join(:code.priv_dir(:exqlite), 'sqlite3_nif')
    :erlang.load_nif(path, 0)
  end

It looks like this is because the priv/ directory is not supproted in escript.

It looks like NIFs in general cannot work in escript. Bummer.

Where Next?

Popular in Questions Top

Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement