`replace_string_in_file` reports success but doesn't persist changes
まだ誰も着手していません。
評価
調査の方向性
まず、Xcode workspace 内の影響を受ける Swift ファイルで replace_string_in_file を再現し、そのディスク上の結果を insert_edit_into_file と比較します。replace_string_in_file のエントリポイントを追跡し、成功した編集が保持されること、また書き込みに失敗した場合や一致する置換がない場合に成功ではなくエラーが報告されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
The replace_string_in_file editing tool consistently reports successful edits but fails to write changes to disk, requiring escalation to insert_edit_into_file. This silent failure wastes significant time and breaks trust in the tool.
Core Problem
What happens:
- Tool reports: "✅ The following files were successfully edited"
- File on disk remains unchanged (verified via
grep,sed) - Compilation errors persist for missing code
- No error message or warning given
Scale: 15-20 failed operations across multiple files in a single session
Reproduction Steps
Attempt 1: Basic Replace
// Trying to add property to struct
OLD: public var existingProperty: Type
NEW: public var existingProperty: Type
public var newProperty: NewType // ← Should be added
Result: Tool reports success, property not added
Attempt 2: More Context
Added 5+ lines of surrounding context for uniqueness
Result: Same false success, no file modification
Attempt 3: Smaller Edits
Broke into multiple atomic replace_string_in_file calls
Result: All reported success, none persisted
Attempt 4: Different Tool (Workaround)
Switched to insert_edit_into_file with full code block
Result: ✅ SUCCESS - File actually modified
Examples of Silent Failures
Example 1: Adding Property
// Attempting to add to line 21:
public var radius: Double
public var newConfig: Config // ← Not added despite success report
public var model: ModelType
Verified via: grep "newConfig" File.swift (no results)
Example 2: Renaming Class
OLD: public class OldName {
NEW: public class NewName {
Verified via: grep "class NewName" (empty - still OldName)
Example 3: Updating Parameters
Changed type in 4 method signatures
All 4 reported success, none actually changed
Verified via: grep "OldType" (still 4 occurrences)
File Context
Common factors:
- Xcode workspace (
.xcworkspace) - Swift files (
.swift) - Some had extended attributes (
@flag) - Files actively loaded in Xcode
- 100-30,000 lines
- Complex Swift (generics, protocols, async/await)
Impact
- Time lost: 60-80 minutes debugging
- Trust: Tool reliability undermined
- Workflow: Required terminal verification for every edit
- Escalation: Eventually abandoned
replace_string_in_fileentirely
Expected vs Actual Behavior
| Expected | Actual |
|---|---|
| File modified on disk | File unchanged |
| Compilation reflects changes | Compilation errors persist |
| Subsequent reads show new content | Old content remains |
| OR: Error reported if write fails | False success reported |
Successful Workaround
# 1. Detect failure with terminal:
grep "expected_symbol" file.swift # (no output)
sed -n 'line,linep' file.swift # Shows old code
# 2. Use insert_edit_into_file instead:
# - Provide complete code block
# - Use // ...existing code... comments
# - Tool writes successfully
# 3. Verify after edit:
grep "expected_symbol" file.swift # Now found
Potential Causes
- File caching - Editor cache not flushed
- Xcode locks - Files locked by IDE
- Extended attributes -
@flag preventing writes - Path resolution - Writing to wrong location
- Silent match failure - Can't find string, reports success anyway
Recommended Fixes
- Verify writes - Read file back after write to confirm
- Report actual errors - Show permission/lock failures
- Flush buffers - Explicitly sync to disk before success
- Detect locks - Check if Xcode has file locked
- Auto-fallback - Suggest
insert_edit_into_fileon failure
Evidence
# Tool says success:
✅ The following files were successfully edited: /path/to/File.swift
# Reality check:
$ grep "newProperty" File.swift
# (no output - property was NOT added)
$ sed -n '19,23p' File.swift
public var oldProperty: Type
public var anotherOld: Type
# (missing newProperty that should be between them)
Reproducibility
- Frequency: 100% for affected files
- Pattern: Consistent across multiple file types/sizes
- Workaround:
insert_edit_into_filealways worked
Key Observation
The fact that insert_edit_into_file works reliably suggests this is a replace_string_in_file-specific issue, not a general file writing problem.
Priority: High - Core functionality broken
Request: Investigate silent failures in Xcode workspace context with Swift files
- 主要言語
- Swift
- スター
- 6.3k
- フォーク
- 2k
- 平均マージ
- 3日 21時間
- マージ済み PR(30日)
- 2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/CopilotForXcode のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
github/CopilotForXcode#181 · リアクション 2 件 ·
-
Add ability to attach Copilot window only to Xcode projects/workspaces, ignoring standalone files オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
github/CopilotForXcode#945 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
github/CopilotForXcode#943 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
github/CopilotForXcode#936 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
github/CopilotForXcode#934 ·
github/CopilotForXcode の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
manaflow-ai/cmux#13763 ·
-
type: feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-swift#1036 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
wultra/mtoken-sdk-ios#253 ·
-
area:dictation documentation P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
uttrflow/uttrflow-swift#1180 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100