Skip to content

Commit 771ba8f

Browse files
author
Factory Bot
committed
fix: CI compilation errors across platforms
- Fix set_var unsafe in Rust 2024 edition (cortex-utils-pty) - Fix ptsname_r not available on macOS (use ptsname instead) - Fix permissions variable not in scope (cortex-engine/tasks/snapshot.rs) - Allow expect/unwrap in cortex-protocol tests - Remove unused import in skills/manager.rs
1 parent 3ba302f commit 771ba8f

6 files changed

Lines changed: 37 additions & 4 deletions

File tree

ci_logs.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gh : run 21363633308 is still in progress; logs will be available when it is complete
2+
Au caractère Ligne:1 : 64
3+
+ ... s\Hi\Documents\cortex-cli; gh run view 21363633308 --log 2>&1 | Out-F ...
4+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
+ CategoryInfo : NotSpecified: (run 21363633308... it is complete:String) [], RemoteException
6+
+ FullyQualifiedErrorId : NativeCommandError
7+

clippy_log.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gh : run 21363633308 is still in progress; logs will be available when it is complete
2+
Au caractère Ligne:1 : 38
3+
+ ... ocuments\cortex-cli; gh run view --job=61489287108 --log 2>&1 | Out-F ...
4+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
+ CategoryInfo : NotSpecified: (run 21363633308... it is complete:String) [], RemoteException
6+
+ FullyQualifiedErrorId : NativeCommandError
7+

cortex-engine/src/skills/manager.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use once_cell::sync::OnceCell;
1313
use tracing::warn;
1414

1515
use super::{Skill, SkillRegistry, SkillScope};
16-
use crate::error::Result;
1716

1817
/// Error that occurred while loading a skill.
1918
#[derive(Debug, Clone)]

cortex-engine/src/tasks/snapshot.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ impl SnapshotManager {
292292
match state {
293293
FileState::Exists {
294294
content,
295-
permissions: _,
295+
#[cfg(unix)]
296+
permissions,
297+
#[cfg(not(unix))]
298+
permissions: _,
296299
..
297300
} => {
298301
// Create parent directories

cortex-protocol/src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Comprehensive tests for Cortex-protocol
2+
#![allow(clippy::unwrap_used, clippy::expect_used)]
23

34
#[cfg(test)]
45
pub mod approvals_tests;

cortex-utils/pty/src/pty.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl UnixPty {
7474
}
7575

7676
/// Get the name of the slave PTY.
77+
#[cfg(target_os = "linux")]
7778
fn get_slave_name(master_fd: RawFd) -> io::Result<CString> {
7879
let mut buf = [0i8; 256];
7980
let result = unsafe { libc::ptsname_r(master_fd, buf.as_mut_ptr(), buf.len()) };
@@ -85,6 +86,19 @@ impl UnixPty {
8586
Ok(cstr.to_owned())
8687
}
8788

89+
/// Get the name of the slave PTY.
90+
/// macOS doesn't have ptsname_r, use ptsname instead.
91+
#[cfg(target_os = "macos")]
92+
fn get_slave_name(master_fd: RawFd) -> io::Result<CString> {
93+
let ptr = unsafe { libc::ptsname(master_fd) };
94+
if ptr.is_null() {
95+
return Err(io::Error::last_os_error());
96+
}
97+
98+
let cstr = unsafe { std::ffi::CStr::from_ptr(ptr) };
99+
Ok(cstr.to_owned())
100+
}
101+
88102
/// Setup the child process with the slave PTY.
89103
fn setup_child(slave_name: &CString, cmd: &str, args: &[&str], config: &PtyConfig) -> ! {
90104
// Create a new session
@@ -127,13 +141,15 @@ impl UnixPty {
127141
}
128142

129143
// Set environment variables
144+
// SAFETY: We are in the child process after fork, single-threaded at this point
130145
for (key, value) in &config.env {
131-
std::env::set_var(key, value);
146+
unsafe { std::env::set_var(key, value) };
132147
}
133148

134149
// Set TERM if not already set
150+
// SAFETY: We are in the child process after fork, single-threaded at this point
135151
if !config.env.contains_key("TERM") {
136-
std::env::set_var("TERM", "xterm-256color");
152+
unsafe { std::env::set_var("TERM", "xterm-256color") };
137153
}
138154

139155
// Build the command arguments

0 commit comments

Comments
 (0)