vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Unable to rename folder when I open a file who call this same folder. [Error: EPERM: operation not permitted, rename...]

Open CleverAxel opened this issue 2 years ago • 28 comments

  • VS Code Version: 1.78.2
  • OS Version: Windows 11Professional 22H2

The only extension that I have installed is Tailwind CSS IntelliSense.

Here's a video that shows the bug, I'll try to explain it. : video

When I open VS Code and that no tabs are open, I can rename a folder with one or more folders/files inside it, no problem (but it doesn't give me a dialog box to update the imports.). However when I open a file where this folder is called, I am unable to rename it, it throws an error "Error: EPERM: operation not permitted, rename...".

Same thing if I open a file where the folder is called, close the file then try to rename it, it doesn't allow it. The only that "works" is -> close all the tabs, close VS code, re-open VS Code, rename the folder.

Any clues of where could this issue is coming from ? Thanks.

Edit : Still trying to search and this person on stackoverflow have exactly the same issue : https://stackoverflow.com/questions/74910451/vs-code-unable-to-rename-folder-on-windows-10-i-get-error-eperm-operation-no

CleverAxel avatar Jun 02 '23 10:06 CleverAxel

A little update, I came back home, thinking that it may be Windows 11 (somehow...) but no, the same problem occurs with Windows 10 22H2 as well, unfortunaly.

CleverAxel avatar Jun 02 '23 17:06 CleverAxel

Does it allow you to rename from the OS file explorer?

lramos15 avatar Jun 02 '23 17:06 lramos15

It doesn't allow me to rename it when VS Code access the project where this folder is located because "this folder is already open in another program" . But when VS Code is closed, yes, I can rename it without any issue.

Here's another video where I create the folders from scratch, if it helps to better visualize it https://www.youtube.com/watch?v=BwkmZ0o9ALk

CleverAxel avatar Jun 02 '23 18:06 CleverAxel

I am facing this issue for the past month

hbatalhaStch avatar Jun 07 '23 15:06 hbatalhaStch

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

mjbvz avatar Jun 07 '23 17:06 mjbvz

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

Yes, just installed the latest VS Code insiders build and it is still happening but it usually happens after I start node in my root folder (npm run dev in my case), as soon as I stop node it works normally again.

hbatalhaStch avatar Jun 07 '23 18:06 hbatalhaStch

Could you add more info about your script? Is it doing something with the files in your project?

mjbvz avatar Jun 07 '23 21:06 mjbvz

It is a Next.js project, the script is the same when you create-next-app

hbatalhaStch avatar Jun 07 '23 22:06 hbatalhaStch

is there any solutions? I literally formatted my pc and still get the same problem

Jesusliang avatar Jun 14 '23 12:06 Jesusliang

Now this problem still exists. . . .
image

Basically, every file change (rename and delete) cannot be successful, which has seriously affected the work, qwq

Edge-coordinates avatar Jun 23 '23 14:06 Edge-coordinates

I am still facing this issue

hbatalhaStch avatar Jul 07 '23 10:07 hbatalhaStch

Also having this issue on a React Native project

soyveris avatar Jul 21 '23 00:07 soyveris

Bump. issue still persists. image

hexxone avatar Jul 28 '23 07:07 hexxone

I faced this problem too, and I think it only occurs on Windows since the function works well on my Mac.

yifanwww avatar Oct 01 '23 11:10 yifanwww

I'm also running into this problem, or maybe a different problem with the same error. After spending an hour or so trying to narrow it down, it seems that vs code doesn't like renaming or moving any directory tree that contains a git repository (even a fresh, empty repo). Attempting to do so results in the editor spinning for ~1 minute before giving up and showing the error (though mine is just a notification popup in the tray).

Some additional notes in no particular order:

  • I didn't check any of the various git repository variations other than mkdir test; cd test; git init
  • Closing vscode during the rename makes the rename succeed?
  • Running 'git init' from outside vscode makes a folder which vscode refuses to move
  • Running git init from the vscode terminal (powershell) makes the folder unmoveable, but if you close and reopen the workspace, then the folder can now be moved?
  • Extensions don't seem to matter, the issue still presents when extensions are disabled

P.S. VSCode version is 1.82.2

zdavidsen avatar Oct 04 '23 15:10 zdavidsen

@zdavidsen just a thought - what is your git.autofetch setting?

gjsjohnmurray avatar Oct 04 '23 15:10 gjsjohnmurray

~Whatever the default is, I presume. git config git.autofetch returns nothing~ Oh you meant in vscode, whoops. git.autofetch is false

zdavidsen avatar Oct 04 '23 15:10 zdavidsen

I think it is a duplicate of https://github.com/microsoft/TypeScript/issues/54087

layerok avatar Oct 05 '23 07:10 layerok

The same issue would happen if you use Intellij also. Faced this issue today and neither VSCode nor Intellij cant move or rename folders. If you open Task Manager, and kill all node instances then renaming will work till VSCode or Intellij will spawn an instance of NodeJS.

I think this is related with Typescript server and not VSCode or Intellij.

xeinebiu avatar Oct 13 '23 09:10 xeinebiu

Mine is win10, and it works for me when I run vscode as an administrator.

huo785785 avatar Nov 20 '23 08:11 huo785785

I terminated all node.exe and still can't rename a folder. @xeinebiu Besides, run vscode as an administrator not work for me.

freemedom avatar Dec 08 '23 06:12 freemedom

https://github.com/microsoft/TypeScript/issues/54087#issuecomment-1616680385 I used this method to solve the problem.

freemedom avatar Dec 08 '23 06:12 freemedom

Potential variation on this theme, I'm having trouble building WPF projects in Visual Studio if the folder is open in VSCode at the same time. Taking the suggestion from https://github.com/dotnet/wpf/issues/4299 to disable file watching in **/obj/** worked for me, but the relation to the file watcher made me think this issue may be related

zdavidsen avatar Jan 17 '24 19:01 zdavidsen

Run vscode as an administrator and close any scripts which runs and serves your project and then rename .

mrvcoder avatar Jan 18 '24 10:01 mrvcoder

It just helps to close VS Code and rename/move the folder in file-explorer. I'm on Win 11 and have the latest version of VS Code and i'm also facing these issues.

pxcemaker avatar Jan 26 '24 09:01 pxcemaker

This has been an issue for years with vscode on Windows. I'm not sure it's fixable by vscode because it's a symptom of Windows's poor filesystem behavior (mac/linux never have this issue with their standard filesystems). However, vscode could do a better job of not just spinning for minutes waiting to do the operation which will just fail.

This will often not work if you're running an app server that holds a handle to your files/folders in the project. For example, a nextjs app. Killing those processes and then moving the folder will resolve it.

It's one of the most frustrating things about using vscode on windows, that's for sure.

mlynch avatar Apr 08 '24 13:04 mlynch

This has been an issue for years with vscode on Windows. I'm not sure it's fixable by vscode because it's a symptom of Windows's poor filesystem behavior (mac/linux never have this issue with their standard filesystems). However, vscode could do a better job of not just spinning for minutes waiting to do the operation which will just fail.

This will often not work if you're running an app server that holds a handle to your files/folders in the project. For example, a nextjs app. Killing those processes and then moving the folder will resolve it.

It's one of the most frustrating things about using vscode on windows, that's for sure.

On Intellij, usually I just stop Typescript Language Service, move folders around then enable it back. Only one downside of it, references wont auto update when moving folders.

xeinebiu avatar Apr 08 '24 13:04 xeinebiu

Hey @mjbvz, this issue might need further attention.

@CleverAxel, you can help us out by closing this issue if the problem no longer exists, or adding more information.

vscodenpa avatar Jun 29 '24 11:06 vscodenpa

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

vscodenpa avatar Jul 07 '24 11:07 vscodenpa