Skip to content

Commit

Permalink
fix(core): do not use unix dotfile locks (#28859)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

The unix dotfiles are incompatible with posix dotfiles. Having the 2
modes being switched between yields weird errors.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Posix dotfiles seem fine for what we're doing so Nx will stick with that
mode for all cases.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

(cherry picked from commit 258a256)
  • Loading branch information
FrozenPandaz committed Nov 12, 2024
1 parent decc8d4 commit 7798c5b
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions packages/nx/src/native/db/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rusqlite::{Connection, OpenFlags};
use std::fs::{remove_file, File};
use std::path::{Path, PathBuf};
use tracing::{debug, trace};
use crate::native::utils::ci::is_ci;

pub(super) struct LockFile {
file: File,
Expand Down Expand Up @@ -100,25 +99,13 @@ fn create_metadata_table(c: &mut NxDbConnection, nx_version: &str) -> anyhow::Re
}

fn open_database_connection(db_path: &Path) -> anyhow::Result<NxDbConnection> {
let conn = if cfg!(target_family = "unix") && is_ci() {
trace!("Opening connection with unix-dotfile");
Connection::open_with_flags_and_vfs(
db_path,
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_FULL_MUTEX,
"unix-dotfile",
)
} else {
Connection::open_with_flags(
db_path,
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_FULL_MUTEX,
)
};
let conn = Connection::open_with_flags(
db_path,
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_FULL_MUTEX,
);

conn.map_err(|e| anyhow::anyhow!("Error creating connection {:?}", e))
.map(NxDbConnection::new)
Expand All @@ -139,7 +126,6 @@ fn configure_database(connection: &NxDbConnection) -> anyhow::Result<()> {

#[cfg(test)]
mod tests {

use crate::native::logger::enable_logger;

use super::*;
Expand Down

0 comments on commit 7798c5b

Please sign in to comment.