Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS error: dlsym(0x8a21b620, sqlite3_crsqlitedarwinaarch_init): symbol not found #338

Closed
simonw opened this issue Sep 5, 2023 · 8 comments

Comments

@simonw
Copy link
Contributor

simonw commented Sep 5, 2023

I'm trying to load the https://github.com/vlcn-io/cr-sqlite/releases/download/v0.15.0-next.2/crsqlite-darwin-aarch64.dylib on macOS.

/opt/homebrew/Cellar/sqlite/3.43.0_1/bin/sqlite3
SQLite version 3.43.0 2023-08-24 12:36:59
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .load crsqlite-darwin-aarch64
Error: dlsym(0x8a62b620, sqlite3_crsqlitedarwinaarch_init): symbol not found
sqlite> 

I've tried a few different sqlite3 binaries I had lying around and got the same error in all of them. What am I doing wrong?

@simonw
Copy link
Contributor Author

simonw commented Sep 5, 2023

Aha - just spotted this:

cr-sqlite/README.md

Lines 156 to 158 in 59f03c8

These can be loaded into `sqlite` via the [`load_extension` command](https://www.sqlite.org/loadext.html#loading_an_extension) from any language (Python, NodeJS, C++, Rust, etc.) that has SQLite bindings.
The entrypoint to the loadable extension is [`sqlite3_crsqlite_init` ](https://github.com/vlcn-io/cr-sqlite/blob/92df9b4f3a6bdf2bd7c5d9a76949496fa5dc88cf/core/src/crsqlite.c#L536) so you'll either need to provide that to `load_extension` or rename your binary to `crsqlite.[dylib/dll/so]`. See the linked sqlite [`load_extension` docs](https://www.sqlite.org/loadext.html#loading_an_extension).

@simonw
Copy link
Contributor Author

simonw commented Sep 5, 2023

This worked:

sqlite> .load crsqlite-darwin-aarch64 sqlite3_crsqlite_init

@simonw
Copy link
Contributor Author

simonw commented Sep 5, 2023

Different problem, trying to follow this example in the README:

cr-sqlite/README.md

Lines 85 to 140 in 59f03c8

-- load the extension if it is not statically linked
.load crsqlite
.mode column
-- create tables as normal
create table foo (a primary key, b);
create table baz (a primary key, b, c, d);
-- update those tables to be crrs / crdts
select crsql_as_crr('foo');
select crsql_as_crr('baz');
-- insert some data / interact with tables as normal
insert into foo (a,b) values (1,2);
insert into baz (a,b,c,d) values ('a', 'woo', 'doo', 'daa');
-- ask for a record of what has changed
select * from crsql_changes;
table pk cid val col_version db_version site_id
----- --- --- ----- ----------- ---------- -------
foo 1 b 2 1 1 1(�zL
\hx
baz 'a' b 'woo' 1 2 1(�zL
\hx
baz 'a' c 'doo' 1 2 1(�zL
\hx
baz 'a' d 'daa' 1 2 1(�zL
\hx
-- merge changes from a peer
insert into crsql_changes
("table", pk, cid, val, col_version, db_version, site_id)
values
('foo', 5, 'b', '''thing''', 5, 5, X'7096E2D505314699A59C95FABA14ABB5');
insert into crsql_changes ("table", pk, cid, val, col_version, db_version, site_id)
values
('baz', '''a''', 'b', 123, 101, 233, X'7096E2D505314699A59C95FABA14ABB5');
-- check that peer's changes were applied
select * from foo;
a b
- -----
1 2
5 thing
select * from baz;
a b c d
- --- --- ---
a 123 doo daa
-- tear down the extension before closing the connection
-- https://sqlite.org/forum/forumpost/c94f943821
select crsql_finalize();

I get:

sqlite> insert into crsql_changes
  ("table", pk, cid, val, col_version, db_version, site_id)
  values
  ('foo', 5, 'b', '''thing''', 5, 5, X'7096E2D505314699A59C95FABA14ABB5');
Runtime error: query aborted (4)

@tantaman
Copy link
Collaborator

tantaman commented Sep 5, 2023 via email

@simonw
Copy link
Contributor Author

simonw commented Sep 5, 2023

Gotcha, looks like this is the test to follow: https://github.com/vlcn-io/cr-sqlite/blob/main/py/correctness/tests/test_sync.py

@tantaman
Copy link
Collaborator

tantaman commented Sep 6, 2023

Yep. That uses the latest build (what is in main and the v0.15.xxx releases)

@tantaman
Copy link
Collaborator

tantaman commented Sep 8, 2023

@simonw - I published v0.15 as the official stable release and updated all the docs on the site to match. Should be a smoother experience from here on.

simonw added a commit to simonw/til that referenced this issue Sep 13, 2023
@simonw
Copy link
Contributor Author

simonw commented Sep 13, 2023

Wrote up some of my notes on trying this out here: https://til.simonwillison.net/sqlite/cr-sqlite-macos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants