zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.65k stars 2.92k forks source link

Zed Editor Erroneously Deletes Application Code in iCloud folder #8029

Open ethan-web-dev opened 8 months ago

ethan-web-dev commented 8 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Since last update there has been multiple files lost when using Zed. Have switched to Neovim in the last 24 hrs and side effects relative to file and file content disappearance have stopped entirely.

When editing both next.js and Vite-react apps there have been files disappearing at seemingly random intervals. Both while dev environment is running and is off. It also seems pretty consistent that now, when shutdown/startup occurs, there is a subsequent occurrence where a file is either deleted or its contents are gone entirely without any warning.

To recreate my environment simply create the latest version of the aforementioned apps, create some mock data and fetch it as per either frameworks best practices from a root folder. there are no extra dependencies or complexity beyond that.

This is extremely concerning. Update

This happens to projects that are uploaded to iCloud only. Local folders seem to work fine.

Environment

Zed: v0.122.2 (Zed) OS: macOS 14.2.1 Memory: 8 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

mrnugget commented 8 months ago

Hey @ethan-web-dev! Do you have any concrete steps to reproduce this? It sounds like it's related to having a project in iCloud folder, right? Can you reliably reproduce that?

ethan-web-dev commented 8 months ago

Hey @mrnugget!

I appreciate your prompt response. To provide some clarity, I'm currently operating on a relatively untouched MacBook with standard configurations, and I haven't introduced any custom settings beyond the default ones. Homebrew and node are installed respectively as the machines intended use is for educational purposes surrounding JAMSTACK development.

Regarding the steps to reproduce the issue, I've observed the problem primarily in projects stored within iCloud folders. When files are stored solely in iCloud without being downloaded onto the local machine, the issue arises.

To elaborate:

When project files are backed up to iCloud and aren't locally downloaded (which is the default behavior with Apple's iCloud setup). Upon working on these projects, which were initially created locally but subsequently backed up to iCloud, I've noticed unexpected alterations in the codebase within the editor. Unfortunately, I'm unable to provide a precise, step-by-step reproduction of the issue since it's emerged unexpectedly and inconsistently. With a newly set up machine and no custom configurations, the occurrence of these anomalies is particularly perplexing.

However, after right clicking a backed up folder on my desktop, selecting 'download to desktop' and then restarting Zed, there are no issues.

I hope this sheds some light on the situation.

mrnugget commented 8 months ago

Thanks @ethan-web-dev! That should help to investigate further.

CobyPear commented 6 months ago

I just went back to a file after trying to debug an issue that just started and my file was blank. Undo DID NOT work. This is very frustrating as I did not have a recent commit and no other backup.

I am on macos 14.4 and the project folder is not linked to icloud. The application is also vite based, SvelteKit in this case.

ethan-web-dev commented 6 months ago

@mrnugget I have dug into this issue further since seeing @CobyPear 's comment.

Coby - try downloading the file/files from iCloud. You likely have "Optimize Storage" set as a default iCloud setting which I have found to be the culprit, at least in my case.

Do yourself the favour of downloading only the application code from iCloud, ignore downloading the node modules folder. After you're done rerun your package manager install to get node_modules back. It's easy to accidentally download the entire application code include node_modules but save yourself the headache.

IF the file(s) are downloaded to the machine you should have no issue accessing them.

Thorsten - The issue isn't deletion of application code, it is just being misplaced by iCloud once the file is closed and after being misplaced it is unreadable by Zed. Not so much a Zed pitfall but rather an Apple one. When testing other IDE's (neovim, vscode, atom, sublime) they do not face the same issue as consistently as when using zed, but I was able to recreate the issue with a barebones neovim editor config but I haven't been able to distill a reason 'why'.

Spitballing here, I believe due to the way iCloud handles on demand data retrieval, and Zed not having the correct permissions to access and retrieve said data on demand, is the underlying cause.

I know that iCloud has certain api's responsible for accessing/downloading or streaming the data via desktop application but to my knowledge that is only available through cloudkit.

To reproduce the issue follow the steps below:

  1. turn on "Optimize Mac Storage" in 'system settings'>'Apple ID'>'iCloud'

  2. allow all apps to use iCloud

  3. make a file, write some code (shouldn't matter what language, I have had this issue occur in a few different languages now)

  4. close the file and reopen it after some time

there is a caveat to the fourth step, there is no consistency to the timeline in which the files contents become unretrievable.

I had originally written this out last night but could not get the contents of the file to disappear after 3 hours of shutting my machine down, closing the editor, etc. Only until I opened up my laptop this morning was I able to see the issue manifest.

I hope this helps, I want to see you guys win.

CobyPear commented 6 months ago

@ethan-web-dev thanks for the reply. Maybe I should open a new issue since my project files are in no way linked to iCloud. Unless macos puts all of my home dir in iCloud without my knowledge, I have not used iCloud on this machine at all.

ethan-web-dev commented 6 months ago

@CobyPear Sorry, I should have read more carefully.

That is alarming, contrary to your problem, I have had great success with Zed when the files are downloaded to the machine.

In your case perhaps running a First Aid scan would be a good place to start? I have tried Zed on 3 different Macs now (i5, m1, m2) and the issue is consistent for me across the board.

Send me a message if you like, I definitely know Macs better than I know rust or the Zed codebase!

mrnugget commented 5 months ago

@ethan-web-dev thanks for the write-up! If I understand you correctly, this means that other editors/IDEs seem to do better than Zed when it comes to iCloud files, but they are also not 100% safe from this issue, is that correct?

@CobyPear yeah, I think opening a new issue with concrete steps to reproduce would be the best option, thanks!

ethan-web-dev commented 5 months ago

@mrnugget Yes, that is a correct summary.

As for VS Code, it just works. I've been 'beating it up', so to speak, to see if I can get it to behave in a way where the file contents are empty/lost but from what I have observed, it fetches the contents when the file is reopened if the contents are not already populated.