cargo-quickinstall icon indicating copy to clipboard operation
cargo-quickinstall copied to clipboard

`sqlx-cli`: Divergence between versions: `cargo binstall` vs `cargo install`

Open s373r opened this issue 1 year ago • 5 comments

While recently investigating the error, I concluded that something was wrong with the compiled version of sqlx-cli.

In brief:

### binstall
cargo binstall sqlx-cli -y --force

sqlx database create --database-url sqlite://test.sqlite.db
# error: error returned from database: (code: 14) unable to open database file

################################################################################

### install
cargo install sqlx-cli --force

sqlx database create --database-url sqlite://test.sqlite.db
# no errors

I'd be happy to help with testing, research if needed

s373r avatar Aug 05 '24 17:08 s373r

I think it might be related to the features enabled?

https://docs.rs/crate/sqlx-cli/latest/features

NobodyXu avatar Aug 06 '24 12:08 NobodyXu

I thought so too at first, but sqlite is the default enabled feature -- and if features are not explicitly specified in cargo install (which is our case), the default features will be used by default.

s373r avatar Aug 06 '24 14:08 s373r

I think it's related to rusqlite

If --features=bundled is enabled, the vendored source of SQLite will be compiled and linked in. SQLite is in the public domain, as described here.

AFAIK the bundled isn't enabled, so sqlx just linked to our system-wide libsqlite3.

That might be the reason for it.

I checked its doc, I didn't find any environment for forcing vendor, only found SQLITE3_STATIC

So it'd be great if sqlx can have a vendored feature to vendor everything, I could enable it in quickinstall.

NobodyXu avatar Aug 06 '24 15:08 NobodyXu

[dependencies.libsqlite3-sys]
version = "0.30.1"
default-features = false
features = [
    "pkg-config",
    "vcpkg",
    "bundled",
    "unlock_notify"
]

(c) source

it looks like a bundled version is being used...

--

Also of note is this ticket (discussion): https://github.com/launchbadge/sqlx/issues/191 , which asks for sqlx to be able to build with system-wide libsqlite.

s373r avatar Aug 07 '24 12:08 s373r

Update: the issue mentioned above has been finished, but there has been no sqlx release yet

  • https://github.com/launchbadge/sqlx/issues/191

s373r avatar Oct 16 '24 10:10 s373r