Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Unable to move file to trash upon delete #13189

Closed
rajinder-yadav opened this issue Oct 4, 2016 · 48 comments
Closed

Linux: Unable to move file to trash upon delete #13189

rajinder-yadav opened this issue Oct 4, 2016 · 48 comments
Assignees
Labels
electron Issues and items related to Electron upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@rajinder-yadav
Copy link

rajinder-yadav commented Oct 4, 2016

  • VSCode Version: Code 1.5.3 (5be4091, 2016-09-22T08:40:08.699Z)
  • OS Version: Linux x64 4.4.0-38-generic

Steps to Reproduce:

  1. Select file
  2. Press delete key

This use to work, now I get the following error message:

Failed to move 'app.component.css' to the trash

I am then asked each time to click on the "Delete Permanently" button to actually delete the file?

del

@bpasero
Copy link
Member

bpasero commented Oct 5, 2016

@rajinder-yadav this indicates that the folder you have opened is maybe not able to move to trash, this can happen if the folder is from a network drive for example or you need other permissions to do so. Does it reproduce with any folder you open?

@bpasero bpasero added the info-needed Issue requires more information from poster label Oct 5, 2016
@bpasero bpasero added this to the Backlog milestone Oct 5, 2016
@bpasero bpasero added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Oct 5, 2016
@rajinder-yadav
Copy link
Author

There are 2 places I work from, my home folder or under /tmp in both cases I had no issues about deleting files. I just notice this problem the other day, I even tried restarting vscode, then I emptied my trash just to make sure it was not full. The problem persisted.

I don't know what caused it, it happen once so far. I just created a new project and was able to delete files, so I am not sure how to repro it yet, just that it happened and would not go away.

@bpasero
Copy link
Member

bpasero commented Oct 5, 2016

@rajinder-yadav and can you move to trash if you use the windows explorer?

@rajinder-yadav
Copy link
Author

rajinder-yadav commented Oct 5, 2016

It's on Linux, and yes I can move files to from trash using the file explorer, both locations have global read/write permission.

@bpasero
Copy link
Member

bpasero commented Oct 5, 2016

Ah sorry, didn't see this was linux. Looks like an upstream electron issue then, we just call into their function. If you can reproduce using Atom, I suggest filing a bug against them.

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Oct 5, 2016
@bpasero bpasero changed the title Unable to delete file Linux: Unable to move file to trash upon delete Oct 5, 2016
@davidgiven
Copy link

I don't have a trash. Is there any chance of a configuration option to change 'Delete file' to unconditionally remove the file moving trying to move it to the trash?

@bpasero
Copy link
Member

bpasero commented Jan 14, 2017

@davidgiven you can hold the Shift key and delete to bypass trash anytime.

@rajinder-yadav
Copy link
Author

rajinder-yadav commented Jan 15, 2017

Delete issue on Linux resolved for me. found this:

https://code.visualstudio.com/docs/setup/linux#_debian-and-moving-files-to-trash

One annoying thing, please add a setting to stop making me confirm the delete.

@sk33wiff
Copy link

@rajinder-yadav I've tried that on ubuntu 16.10 but it didn't worked. What distro are you using?

@rajinder-yadav
Copy link
Author

@marcelopm Kubuntu 16.10

@sk33wiff
Copy link

This workaround seems to partially solve the issue:

sudo mkdir /.Trash-1000
sudo chown user:user /.Trash-1000

ref: https://github.com/atom/tree-view/issues/=345#issuecomment-125778929

But now I have two trashcans, which is quite annoying specially because one is integrated to my desktop manager and the other is not.

BTW soft-linking it to ~/.local/share/Trash doesn't work neither does mount bind: sudo mount -o rbind /home/user/.local/share/Trash /.Trash-1000

@rajinder-yadav
Copy link
Author

@bpasero going to open a new feature request to request silencing of getting nagged "are you sure" each time I want to delete a file.

@rajinder-yadav
Copy link
Author

rajinder-yadav commented Jan 28, 2017

@marcelopm you're going to forget to empty one of those trash can now, I would not recommend this solution. It actually creates a new problem!

@sk33wiff
Copy link

👍

@xavadu
Copy link

xavadu commented Mar 2, 2017

@marcelopm the workaround of create a directory /.Trash-1000 worked for me

+1 to solve this bug

@mengstr
Copy link

mengstr commented Mar 9, 2017

This issue was fixed by sudo apt-get install gvfs-bin on my old Lubuntu machine.

But I would +1 for a flag to kill the popup window asking if I really want to put the file in trash. I don't need to be reminded that I can restore files from trash. For a permanent delete this question might be relevant though. But still.. If I permanently delete a file by mistake I can always restore it from git, so even in that case the question is a little bit too "nanny" for me. ;-)

@bpasero bpasero added workbench file-explorer Explorer widget issues and removed workbench bug Issue identified by VS Code Team member as probable bug labels Apr 7, 2017
@mecp
Copy link

mecp commented Jun 1, 2017

Ubuntu:
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

Visual Studio Code:
Version 1.12.2
Commit 19222cdc84ce72202478ba1cec5cb557b71163de
Date 2017-05-10T13:16:25.899Z
Shell 1.6.6
Renderer 56.0.2924.87
Node 7.4.0

Still facing this issue.

@davidgiven
Copy link

Still happening in 1.14.2, still an everyday annoyance...

(Vscode shouldn't be assuming that a trash exists, or exists in a particular place --- they're not universal on Linux. This really needs to be configurable.)

@bpasero bpasero added the electron Issues and items related to Electron label Nov 12, 2017
@mgolebiowski
Copy link

mgolebiowski commented Feb 19, 2018

Trash stopped working on vscode started from shell after upgrade to 1.20.1. Ubuntu 17.10.

1.20.1
f88bbf9137d24d36d968ea6b2911786bfe103002
x64

@scurest
Copy link

scurest commented Feb 22, 2018

Trash works if I run with --wait; otherwise it doesn't.

$ code --version
1.20.1
f88bbf9137d24d36d968ea6b2911786bfe103002
x64

@caub
Copy link

caub commented Feb 25, 2018

Same here, on linux too. If I delete a file from native file explorer, it goes to trash like expected.

If I delete using vscode, I always have the prompt:
2018-02-25-170508_1570x88_scrot
(even with "explorer.confirmDelete": false) and pressing delete permanently doesn't move it to trash.

A Direct delete that goes in trash is actually much safer than a prompt for this no-trash delete.
(shift-delete works directly too, but without the trashing it's super unsafe)

So the current way is more annoying, and less safe.
I don"t really want to create those .Trash-1000 local folders per project too

It's an electron issue as it appears?

edit I've an older laptop, same OS, where the deletion from vscode works fine, like native file explorer, and deleted files go in trash. Need to figure out, both vscode have same settings

Oh I think it's what @mgolebiowski said, the older laptop has an older version of vscode, upgrading to latest to check


@bpasero Yes confirmed:

As of version

1.20.1
f88bbf9137d24d36d968ea6b2911786bfe103002
x64

vscode is not able to send files to trash anymore, when deleting (when launching vscode from terminal: code ., as @kdar points out, it still works if launched from desktop)

@ppozniak
Copy link

ppozniak commented Mar 5, 2018

Same issue
image

Ubuntu 17.10
1.20.1
f88bbf9137d24d36d968ea6b2911786bfe103002
x64

And also only happens when I run VSC from terminal code .

@luisfpg
Copy link

luisfpg commented Mar 5, 2018

See this pull request: electron/electron#7178

In my case (Antergos Linux, which is Arch based), the problem is that the gvfs has been deprecated in favor of gio.
So, if I set the following environment variable before launching VSCode, it works: ELECTRON_TRASH=gio.
Note that gio backend was added later than the original pull request I mentioned earlier.
Probably at some point the default will change from gvfs to gio, but until then, the workaround works.

@brad-jones
Copy link

On Fedora 27, added ELECTRON_TRASH=gio to my .bashrc problem fixed.

@FatalEnigma
Copy link

Same issue with redhat 7.4. Manually calling gvfs-trash on a file works okay but not from within vs code or indeed atom. Happens when launching from desktop or command line. Switching to gio appears to fix it though.

@jhidding
Copy link

jhidding commented Mar 23, 2018

Working on Debian, with my data stored in a separate partition.

I have created a /.Trash folder manually as described in the XDG specifications, deleting files from Nautilus creates a subfolder /.Trash/1000 (as it should according to the specs); however VS Code still doesn't know how to trash my files. Setting ELECTRON_TRASH=gio does work here.

@yoyoys
Copy link

yoyoys commented Apr 6, 2018

@brad-jones i've added that, but still not working.

but ELECTRON_TRASH=gio code . works.

Ubuntu 17.10

@apihlaja
Copy link

apihlaja commented Apr 7, 2018

Has anyone looked at why launching from terminal behaves differently? Why does it use wrong driver in one case but not in other?

@lonix1
Copy link

lonix1 commented Jul 1, 2018

Still broken in Ubuntu 18.04, with gvfs-bin already installed.

Problem only when launching via code .

@diegoquintanav
Copy link

diegoquintanav commented Jul 7, 2018

Still broken with latest release and gvfs-bin installed.

code --version 
1.25.0
0f080e5267e829de46638128001aeb7ca2d6d50e
x64

deleting file works perfectly fine if I open it from the desktop launcher instead of a terminal. I'm using ubuntu 18.04.

@PopularDemand
Copy link

PopularDemand commented Jul 9, 2018

I fixed this problem by installing the .deb available through the official downloads page NOT the Visual Studio Code application available by default in the Ubuntu Software Center.

  1. Uninstall "Visual Studio Code"
  2. Download and install the application from the official page

@diegoquintanav
Copy link

diegoquintanav commented Jul 9, 2018 via email

@mgolebiowski
Copy link

I use .debs from downloads page and the problem occurs anyways.
For now the always working fix is exporting ELECTRON_TRASH=gio before running $ code command as @brad-jones proposed.

@lonix1
Copy link

lonix1 commented Jul 28, 2018

A workaround until this bug is fixed:

sudo mv /usr/bin/code /usr/bin/codeReal
sudo sh -c "echo 'ELECTRON_TRASH=gio codeReal \$1' >> /usr/bin/code"
sudo chmod 777 /usr/bin/code         # same permissions as original

Then use code . as usual.

(Works for me with Ubuntu 18.04.1 LTS and vscode 1.25.1)

@manuel-di-iorio
Copy link

manuel-di-iorio commented Aug 13, 2018

Added ELECTRON_TRASH=gio into the file ~/.bashrc, to make it permanent. Now moving to the trash works when launching by code .

But not if I directly launch vscode through the ubuntu dash/dock/ubuntu software or by right click on the folder > open with the application vscode


Ubuntu 18.04.1 LTS
VSCode 1.125.1

@kramerc
Copy link

kramerc commented Aug 14, 2018

@manuel-di-iorio Try adding export ELECTRON_TRASH=gio to either ~/.profile or in a file in /etc/profile.d/ instead. That should make it work when launching from a GUI after you log out and log back in.

@manuel-di-iorio
Copy link

@kramerc it worked by adding the line into the ~/.profile file, thank you so much

@bpasero
Copy link
Member

bpasero commented Sep 12, 2018

Fyi there is now (tomorrows insider build) a setting files.enableTrash to disable the usage of the trash when deleting in case someone really cannot or does not want to use the trash (ref: #14638 (comment))

@bpasero bpasero removed file-io File I/O labels Sep 20, 2018
@piec
Copy link

piec commented Dec 3, 2018

FYI: Electron 3 fixes this, it replaces the usage of the deprecated gvfs-trash by gio instead as fallback (part of glib2) if it can't determine the Desktop Environment.
source

@bpasero
Copy link
Member

bpasero commented Jan 25, 2019

Closing this issue given that we plan to release VSCode stable early February with Electron 3.x. If you want to benefit from the fix already, consider to use our insiders version that already contains the fix: https://code.visualstudio.com/insiders/

@bpasero bpasero closed this as completed Jan 25, 2019
@bpasero bpasero added this to the December/January 2019 milestone Jan 25, 2019
@travisdowns
Copy link

For what it's worth the ELECTRON_TRASH=gio workaround didn't work for for me on Ubuntu 16.04, but ELECTRON_TRASH=gvfs-trash does. Perhaps the gio approach doesn't work on Ubuntu 16.04.

 code --version
1.31.1
1b8e8302e405050205e69b59abb3559592bb9e60
x64

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
electron Issues and items related to Electron upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests