Skip to content

Fix rust build on windows - #2019

Merged
bolinfest merged 5 commits into
openai:mainfrom
joshleblanc:fix-windows
Aug 8, 2025
Merged

bolinfest merged 5 commits into
openai:mainfrom
joshleblanc:fix-windows

Conversation

@joshleblanc

Copy link
Copy Markdown
Contributor

This pull request implements a fix from #2000, as well as fixed an additional problem with path lengths on windows that prevents the login from displaying.

@github-actions

github-actions Bot commented Aug 8, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@joshleblanc

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@bolinfest bolinfest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!

Please see comment: I would prefer tempfile::NamedTempFile unless there's a compelling reason why we can't.

Comment thread codex-rs/login/src/lib.rs Outdated
pub stderr: Arc<Mutex<Vec<u8>>>,
}

fn ensure_login_script(codex_home: &Path) -> std::io::Result<PathBuf> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of writing to CODEX_HOME, can we use tempfile::NamedTempFile in the OS temp directory? The main thing I care about is that as part of Drop, it should be deleted.

I suppose that still works if the tempfile::NamedTempFile is created in CODEX_HOME, but it's possible it won't get cleaned up in the event of a panic, so I think we should stick with the temp folder unless there is a compelling reason not to.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you need to return the NamedTempFile from this function so it stays alive.

Comment thread codex-rs/login/src/lib.rs Outdated
pub stderr: Arc<Mutex<Vec<u8>>>,
}

fn ensure_login_script(codex_home: &Path) -> std::io::Result<PathBuf> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn ensure_login_script(codex_home: &Path) -> std::io::Result<PathBuf> {
fn ensure_login_script(codex_home: &Path) -> std::io::Result<NamedTempFile> {

Comment thread codex-rs/login/src/lib.rs Outdated

/// Spawn the ChatGPT login Python server as a child process and return a handle to its process.
pub fn spawn_login_with_chatgpt(codex_home: &Path) -> std::io::Result<SpawnedLogin> {
let script_path = ensure_login_script(codex_home)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the names, but:

Suggested change
let script_path = ensure_login_script(codex_home)?;
let script_file = ensure_login_script(codex_home)?;
let script_path = script_file.path();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I suppose the NamedTempFile has to be a field of SpawnedLogin for the lifetime to work out?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, tracing this through, we would have to get this all the way to spawn_completion_poller() in codex-rs/tui/src/onboarding/auth.rs, which I admit is a bit gross. I guess we should stick with keep()?

Comment thread codex-rs/login/src/lib.rs Outdated
Comment on lines +273 to +274
let (_file, path) = tmp.keep()?;
Ok(path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By returning NamedTempFile, we don't have to invoke keep(), which is the goal.

@bolinfest

Copy link
Copy Markdown
Collaborator

@joshleblanc I am trying to push up my fix, but the colon in the branch name is killing me:

git co -b 'joshleblanc:fix-windows'
fatal: 'joshleblanc:fix-windows' is not a valid branch name

@bolinfest

Copy link
Copy Markdown
Collaborator

I updated login/src/lib.rs via the GitHub web UI, but I can't make the change to login/Cargo.toml that I need to make via the web UI...

@bolinfest

Copy link
Copy Markdown
Collaborator

Oh, I see: I'm not used to trying to push to a branch outside my organization...

@bolinfest

Copy link
Copy Markdown
Collaborator

OK, I'm learning a lot about GitHub today...was able to make the Cargo.toml change, as well.

@bolinfest
bolinfest merged commit 216e9e2 into openai:main Aug 8, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 8, 2025
@joshleblanc
joshleblanc deleted the fix-windows branch August 8, 2025 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants