Description
This issue appears on the latest commit to main at the time of writing this.
Bug Description
The PR to implement one file per query: #2363 implemented logic to write queries to a temp file and then persist them to SQLX_OFFLINE_DIR
here:
sqlx/sqlx-macros-core/src/query/data.rs
Lines 163 to 170 in c03926c
However, the docs for NamedTempFile::persist
mention the following:
Note: Temporary files cannot be persisted across filesystems.
On Linux, the /tmp
directory is commonly mounted as tmpfs
which means the call to tmp_file.persist
will result in the following error: failed to move query file: PersistError(Os { code: 18, kind: CrossesDevices, message: "Invalid cross-device link" })
.
Perhaps we could use tempfile::NamedTempFile::new_in(dir.as_ref())
to create the temporary files directly in SQLX_OFFLINE_DIR
to ensure we're not crossing any filesystem boundaries?
Minimal Reproduction
Run cargo sqlx migrate
on a Linux system with /tmp
mounted separately from the main OS.
Info
- SQLx version: 0.7.0-alpha.1
- SQLx features enabled: "sqlite", "any", "macros", "runtime-tokio"
- Database server and version: SQLite
- Operating system: Arch Linux
rustc --version
: rustc 1.68.0 (2c8cc3432 2023-03-06)