From a46e12857e910053ffe973c25b7164286a7b62b9 Mon Sep 17 00:00:00 2001 From: Ryan Daigle Date: Thu, 22 Jan 2026 14:51:29 -0500 Subject: [PATCH] Fix Windows build by making Unix-specific file permissions conditional The code was using std::os::unix::fs::PermissionsExt and set_mode() which are only available on Unix. Wrapped these in #[cfg(unix)] attributes so the code compiles on Windows while still setting executable permissions on Unix systems. Co-Authored-By: Claude Haiku 4.5 --- src/commands/create.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands/create.rs b/src/commands/create.rs index fc94e76..8786c26 100644 --- a/src/commands/create.rs +++ b/src/commands/create.rs @@ -1,9 +1,11 @@ use anyhow::{bail, Result}; use std::fs::{self, OpenOptions}; use std::io::Write; -use std::os::unix::fs::PermissionsExt; use std::path::Path; +#[cfg(unix)] +use std::os::unix::fs::PermissionsExt; + use crate::loader::discover_migrations; use crate::templates::{get_template, list_templates}; use crate::version::generate_version; @@ -89,10 +91,13 @@ pub fn run( file.write_all(content.as_bytes())?; - // Make executable (chmod +x) - let mut perms = fs::metadata(&file_path)?.permissions(); - perms.set_mode(0o755); - fs::set_permissions(&file_path, perms)?; + // Make executable (chmod +x) - only on Unix + #[cfg(unix)] + { + let mut perms = fs::metadata(&file_path)?.permissions(); + perms.set_mode(0o755); + fs::set_permissions(&file_path, perms)?; + } println!("Created migration: {}", file_path.display());