# Apply code update from chat creates a new file

**URL:** <https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347>\
**Category:** Bug Reports\
**Created:** [October 11, 2024, 10:01pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347 "2024-10-11T22:01:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 11, 2024, 10:01pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/1 "2024-10-11T22:01:52Z")

</div>

In the previous version 0.41.3 a code update to my file it would apply it to the correct file. An update came I accepted the update. when it reopened this started happening. Now it creates a new file in a new folder with the updated code. I uninstalled and reinstalled the previous version and the issue still persists. Anyone have thoughts on how to fix this?

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [October 12, 2024, 9:00am UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/2 "2024-10-12T09:00:17Z")

</div>

Hi @Dan.Lane

Could you show me the steps to reproduce it?

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 5:06pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/3 "2024-10-12T17:06:34Z")

</div>

I want to share the video recording of the bug but for some reason, I am not allowed to upload a video in the forum… let me take screenshots and see if that will show.

 ![image](https://us1.discourse-cdn.com/cursor1/original/2X/f/fd14c68d4e07e2448f00194299ce1316d96d4308.png)  
Let me know if you need further explanation.

and because I am a new user I can only upload one image… ughhh…

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 5:07pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/4 "2024-10-12T17:07:19Z")

</div>

![image](https://us1.discourse-cdn.com/cursor1/original/2X/a/aa7a9e8fe9a1ff76924d7a057f505b09f48f83c0.png)  
had to wait 16 seconds to post…

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [October 12, 2024, 5:12pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/5 "2024-10-12T17:12:01Z")

</div>

Yeah, it’d be great if you could provide a bit more detail. I can’t quite figure out what’s happening from the screenshots. You could also record a YouTube Shorts video and send the link.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 6:23pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/6 "2024-10-12T18:23:50Z")

</div>

here is the basics. I asked the chat to review my file and shared it in the chat. It generated the code you see. I click on apply. It created a new file in the incorrect directory structure although it was correct placement it was not in the correct place. I already have the file and it is not updating the file it is rather creating a whole new file in a new directory. Rather than updating the file.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 6:26pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/7 "2024-10-12T18:26:58Z")

</div>

Also if I click on the name in the chat window to the left of ask copy apply it opens the correct file.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 6:27pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/8 "2024-10-12T18:27:29Z")

</div>

![image](https://us1.discourse-cdn.com/cursor1/original/2X/8/8f6de5f1f2a4525167346b16a21009fe8fac5c23.png)

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [October 12, 2024, 6:50pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/9 "2024-10-12T18:50:25Z")

</div>

Wait, but as far as I know, the chat can’t create files, let alone directories. That’s something Composer can do. Maybe you have two identical files in different directories? It happens sometimes.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 7:41pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/10 "2024-10-12T19:41:31Z")

</div>

I added a file to the composer and removed it is still doing it. Not to every file it’s random… If I uninstall and delete the files for Cursor reinstall… will this resolve my issue? what will I lose by doing this? It is causing me to not be able to do as much as I would like as quickly as I would like.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 7:43pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/11 "2024-10-12T19:43:56Z")

</div>

also verified I only have the one file with the files it seems to be doing it to. One other thing is it is doing it to files that chat ai suggests parts of a code for a file. If I click apply for the suggested code change it applies then the next one down for the same file it goes and creates the file in a completely new directory albeit the dir structure is correct as well as the file name.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 8:50pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/12 "2024-10-12T20:50:44Z")

</div>

[](https://www.youtube.com/watch?v=FsFNA8ADtCw)

---

<div class="post-metadata">

**Author:** ![LukeMelas](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/lukemelas/32/8221_2.png) [@LukeMelas](https://forum.cursor.com/u/LukeMelas)\
**Post date:** [October 12, 2024, 10:11pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/13 "2024-10-12T22:11:43Z")

</div>

Thanks for reporting this and for the video! It seems like the apply is thinking you want to edit src/{file} whereas you are actually on {project\_dir}/src/{file}. This is either a model intelligence issue or an issue with our path resolution (perhaps specifically on Windows). We didn’t make any changes to this logic in this new release, so it should not be coming from the new release.

To confirm, this happens on every apply or just on some applies?

CC’ing @shaoruu

(Also @deanrie, it is possible for apply to create a file from chat if apply thinks the code should be added to a file location that doesn’t already exist, but this happens very rarely and when it does happens it is often erroneous).

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 12, 2024, 10:16pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/14 "2024-10-12T22:16:16Z")

</div>

Thank you for your reply. I will try this in the other models and see if that is the fix.

It applies on some of the suggested code updates, not all of them, but when it happens on a particular file and it updates all of the code for that particular file, it will always happen on that file no matter what I do.

---

<div class="post-metadata">

**Author:** ![LukeMelas](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/lukemelas/32/8221_2.png) [@LukeMelas](https://forum.cursor.com/u/LukeMelas)\
**Post date:** [October 13, 2024, 4:32am UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/15 "2024-10-13T04:32:45Z")

</div>

Hmm strange, thanks for the info. We have someone looking into it trying to reproduce. If it’s ultimately a model intelligence issue, then trying other models should help, as you’ve been doing.

---

<div class="post-metadata">

**Author:** ![Dan.Lane](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Dan.Lane](https://forum.cursor.com/u/Dan.Lane)\
**Post date:** [October 14, 2024, 12:13pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/16 "2024-10-14T12:13:19Z")

</div>

Thank you by the way, I was using sonnet 3.5.

---

<div class="post-metadata">

**Author:** ![pannekoek141](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/pannekoek141/32/8714_2.png) [@pannekoek141](https://forum.cursor.com/u/pannekoek141)\
**Post date:** [October 16, 2024, 10:56am UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/17 "2024-10-16T10:56:34Z")

</div>

I have the same issue, last week when i was working i didn’t have the issue, for now the solution would be to just copy the text from chat instead of pressing the apply button, it does it with all models it seems…

---

<div class="post-metadata">

**Author:** ![mkesin](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mkesin](https://forum.cursor.com/u/mkesin)\
**Post date:** [October 18, 2024, 3:11am UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/18 "2024-10-18T03:11:22Z")

</div>

Same, both windows and osx

---

<div class="post-metadata">

**Author:** ![OldChili](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/oldchili/32/61072_2.png) [@OldChili](https://forum.cursor.com/u/OldChili)\
**Post date:** [October 23, 2024, 2:05am UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/19 "2024-10-23T02:05:12Z")

</div>

I have the same issue with `claude-3.5-sonnet` but it works fine with `gpt-4o`.

When on Sonnet and using Chat, new suggestions always create a new tab and paste the whole code there. They are no longer applied to my code unless I switch models.

---

<div class="post-metadata">

**Author:** ![nbturbo](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@nbturbo](https://forum.cursor.com/u/nbturbo)\
**Post date:** [October 25, 2024, 8:14pm UTC](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347/20 "2024-10-25T20:14:14Z")

</div>

I’m having this issue as well. On MacOS, using claude-3.5-sonnet-20241022. Apply has worked for me in general, but on a set of files I’m working now, if I click apply it creates a file in the wrong path. This is in ‘chat’. I know chat isn’t supposed to create files, but I think it’s doing it as part of the logic of “updating” the file at the wrong path.

In my case I have a VSCode workspace with multiple folders mounted as top-level projects. I’m working in one of the folders, but the “apply” incorrectly happens in another one (the first project in the list).

It’s 100% reproducible with these files. I haven’t experienced this with other uses of apply. Happy to jump on a zoom or something if someone wants to debug this. It’s pretty annoying.

[Next page](https://forum.cursor.com/t/apply-code-update-from-chat-creates-a-new-file/22347.md?page=2)
