Repository navigation
CLIInstaller: write the downloaded CLI in binary mode on every platform - #179
Conversation
File::BINARY is 0 outside Windows, so the download was opened in text mode. With Encoding.default_internal set (Rails sets it to UTF-8), each write transcoded the binary chunks and raised Encoding::UndefinedConversionError on the first byte that is not valid UTF-8, so `bin/rails claude_agent_sdk:install_cli` always failed. Open the file with binmode: true instead. Fixes #177 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016wuLhHzFb7oEoM5Qw39CBj
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Fixes #177
bin/rails claude_agent_sdk:install_clifailed in every Rails app withEncoding::UndefinedConversionError.Http.download_toopened the download withFile::BINARY, which is0outside Windows, so the file was in text mode. Rails setsEncoding.default_internalto UTF-8, and every write then transcoded the binary chunks, raising on the first byte that is not valid UTF-8. The same thing happens outside Rails wheneverdefault_internalis set.The file is now opened with
binmode: true, which also covers whatFile::BINARYdid on Windows.The two other installer IO paths don't need changing:
Metadata.writewrites ASCII only, andMetadata.readusesFile.read(path, limit), which returns a binary string. Checked with external US-ASCII / internal UTF-8 (a common Docker locale), including aVERSIONfile containing non-UTF-8 bytes, which still gets a clean reinstall.Tests
spec/unit/cli_installer_spec.rb: withdefault_internalset to UTF-8,download_towrites non-UTF-8 bytes unchanged. It fails onmainand passes here.spec/unit/cli_installer*_spec.rb: 138 examples, 0 failures. RuboCop: no offenses.🤖 Generated with Claude Code
https://claude.ai/code/session_016wuLhHzFb7oEoM5Qw39CBj
Need help on this PR? Tag
@codesmith-botwith what you need.