Deleting tmp/* files deletes certain app files too

Does anyone else have this problem? Whenever I clear out the /tmp folder, it subsequently also deletes files in the app/style folder and public/assets folder. So I end up having to reset my git repo every time.

It never used to happen until more recently. First couple times I had no clue what was causing it but I can confirm now that doing a “rm -rvf tmp/*” causes files in the app to be deleted.

Are you running ember serve at the same time?

Just happened to me too. I lost around 2-3 days of work. I was just getting into ember and rating it. Now I cannot find a non expletive word to describe how I feel about it.

Yeah, that’s how symlinks work, if you rm -rf tmp/link, it deletes files inside the link’s source. Use rm -rf tmp.

If the files are truly temp files then having symlinks back to the active source which are not temporary does not make sense.

It’s best if input files are copied to generated output folders or included in the path by way of a path lookup system, like a Java class path. That way any output does not have any links to the original source, but the runtime can use files from the source path.

Other code generation systems copy the files to the output ensuring any originals are preserved, an alternate and safer approach.

rm -rf is recursive I think that would remove the link folder anyway?

Ryan

Copying instead of symlinking is hell on performance. Just ask those poor souls on Windows.

No. rm -rf will only remove the symlink when it recurses. It’s the /* that is causing the issue where a top level symlink is followed.

Sucks to lose 2-3 days, perhaps a nudge that it might be worth the time to look into using Git or some other version control tool as it would have rescued you and has heaps of other advantages too :slightly_smiling:

I use rm -rf tmp and have never had any issues so that should be safe.

And never forget to use git… git saves lives :smiley:

I know this is a old topic but I just tried doing a “rm -rf tmp” and it also deleted my public files. This time doesn’t matter too much since it’s in the repo.

But the /* did not matter in my case – deleted it with and without it

(Am on Windows)

I’m sorry, but that is against the specification for rm. I’ve not done much development on Windows lately, but rm -rf is not supposed to remove symbolic links upon recursion according to the POSIX spec. If this doesn’t happen on Windows, that is a bug in rm.

I’ve never had that happen so either you’re mistaken or there is a nasty bug in whatever OS you are using.

Just tried rm -rf tmp with git bash on windows and it deleted source code. Committed source code prior to cleanse this time.

Did some research. This is indeed a bug in Powershell on Windows. https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11087748-powershell-rm-rec-traverses-symbolic-links-and-re

Well, that’s quite unfortunate. I wonder if there is a fix for it since it was posted back in 2012.

For the record, I too am using Git Bash as my main shell. Unsure if that is related to Powershell or not. Either way I hope there is a solution to this.

Update:

It still deletes files using ‘rm’ command in gitbash. And I updated Ember-CLI to 2.5.0 and it still doesn’t automatically clear out tmp folder after exiting ember serve.

So as a temporary fix, I just end up going into the tmp/ folder and Ctrl+A Shift+Delete all the files – doesn’t delete symlinks this method. Tedious but it does the job.