Upgrade SQLite3 binding version?

I’ve given it the requisite hour of googling and experimentation to no avail, so I seek guidance from the experts :)

I’m trying to use the latest version of SQLite3 with a Crystal project, and I can’t figure out how to upgrade the version of the C binding that crystal-sqlite3 uses (sorry if I’m using the wrong terminology).

I was able to get the actual ‘sqlite3’ command to upgrade, but when I execute queries via the crystal-sqlite3 shard, queries are still running against an old version.

Any hints?

How are you installing the updated sqlite3 package?

$ crystal build --verbose ... should show you the link command used. That will probably reveal the paths where the libsqlite3 is looked at.

You can try either:

  • remove the old package or,
  • tweak the LIBRARY_PATH to include the expected library location
  • tweak the CRYSTAL_LIBRARY_PATH to include the expected library location
  • change the crystal-sqlite3 shard to allow pkg_config config lookup (and setup the PKG_CONFIG_PATH variable to include the location of the .pc file)
3 Likes

@bcardiff sorry for the absurdly long response - but I hate leaving threads hanging like this.

Thank you for the response and advice!!

I ended up avoiding the problem on my newer Mac which, when installed fresh, started with the latest version of sqlite3 (3.36.0). Sadly I didn’t get the satisfaction of actually fixing the old issue. But leaving this comment as a placeholder in case I run into this problem again in the future.

I’m glad you have a new machine and things are working. I just created Allow pkg-config to determine library location · Issue #73 · crystal-lang/crystal-sqlite3 · GitHub to have a simpler workaround for the next time.

This does seem to come up a few times a year.

Would it be worth adding a mini-tutorial or video to the SQLite shards readme?

I am thinking it could cover how to compile SQLite and link it.

I posted this last time I saw it come up: How to statically link SQLite extension? - #7 by chillfox

Sure thing! We can drop a .md in the repo or wiki, or if someone publishes an article in dev.to or similar we can link it from the readme directly.

Ok, I will write it up over the weekend.

Edit: Pull request for a basic doc on compiling and linking SQLite.