Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Unable to delete file (need gvfs-trash) #1237

Open
wyqydsyq opened this issue Mar 23, 2018 · 28 comments
Open

Unable to delete file (need gvfs-trash) #1237

wyqydsyq opened this issue Mar 23, 2018 · 28 comments

Comments

@wyqydsyq
Copy link

wyqydsyq commented Mar 23, 2018

When trying to delete a file, I get an error about gvfs-trash, I have gvfs installed, but there is no gvfs-trash on my distro:

$ sudo zypper search gvfs
Loading repository data...
Reading installed packages...

S  | Name               | Summary                                             | Type   
---+--------------------+-----------------------------------------------------+--------
i+ | gvfs               | Virtual File System functionality for GLib          | package
   | gvfs-32bit         | Virtual File System functionality for GLib          | package
i+ | gvfs-backend-afc   | VFS functionality for GLib -- iPod / iPhone Support | package
i+ | gvfs-backend-samba | VFS functionality for GLib -- Samba Support         | package
i+ | gvfs-backends      | VFS functionality for GLib                          | package
   | gvfs-devel         | Development files for the GNOME Virtual file system | package
i+ | gvfs-fuse          | VFS functionality for GLib                          | package
i+ | gvfs-lang          | Translations for package gvfs                       | package
   | xmms2-plugin-gvfs  | Gnome VFS support for xmms2                         | package

There should really be a fallback for this, say, using the standard rm command to delete files if gvfs-trash is not available.

@fmujakitz
Copy link

Had the same issue. Fixed by setting env var for ELECTRON_TRASH=gio.

@lefuturiste
Copy link

lefuturiste commented Jun 26, 2018

Same issue on antergos archlinux
How I can set the env var forever ? What is the command @fmujakitz ?

I have the env variables :

$ printenv | grep ELECTRON
ELECTRON_TRASH=gio

but always the same problem

@wyqydsyq
Copy link
Author

If you want to persist an env var you can add it to your shell's initialization script e.g. .bashrc

@lefuturiste
Copy link

Don't work also

@rsese
Copy link

rsese commented Jun 28, 2018

@lefuturiste does gio trash work ok from the command line?

echo hello > delete-me.txt
gio trash delete-me.txt

@lefuturiste
Copy link

echo hello > delete-me.txt

gio trash delete-me.txt

work well

@rsese
Copy link

rsese commented Jul 3, 2018

@lefuturiste what version of Atom are you running (atom -v)?

@wyqydsyq do you have gio installed on your system? If so, does setting ELECTRON_TRASH work for you?

@lefuturiste
Copy link

@rsese

Atom : 1.28.0
Electron: 2.0.3
Chrome : 61.0.3163.100
Node : 8.9.3

@Dzordzu
Copy link

Dzordzu commented Sep 21, 2018

@rsese
Same here. The issue appeared after last arch update
gio is installed and works like a charm
Files are placed on the same partition, where the atom is

Atom : 1.30.0
Electron: 2.0.9
Chrome : 61.0.3163.100
Node : 8.9.3

@AlynxZhou
Copy link

AlynxZhou commented Sep 23, 2018

It seems that gvfs updates and dropped gvfs-trash, instead we should use gio trash now?

Temp workaround is to create a script as a warpper:

sudo vim /usr/bin/gvfs-trash

Fill it with content:

#!/bin/bash
# GVFS updated and dropped gvfs-trash to gio, but Atom didn't update.
/usr/bin/gio trash "$@"

and then:

sudo chmod +x /usr/bin/gvfs-trash

@pzmarzly
Copy link

This is an Electron issue: electron/electron#15011

@kebertxela
Copy link

It seems that gvfs updates and dropped gvfs-trash, instead we should use gio trash now?
Temp workaround is to create a script as a warpper:

sudo vim /usr/bin/gvfs-trash
#!/bin/bash
# GVFS updated and dropped gvfs-trash to gio, but Atom didn't update.
/usr/bin/gio trash "$@"
sudo chmod +x /usr/bin/gvfs-trash

perhaps this is a slight improvement and a little more copy pasta friendly:

echo '#!/usr/bin/env bash
# GVFS updated and dropped gvfs-trash to gio, but Atom didnt update.
# https://github.com/atom/tree-view/issues/1237
/usr/bin/gio trash "$@"
' | sudo tee /usr/local/bin/gvfs-trash && sudo chmod +x /usr/local/bin/gvfs-trash

@growlnx
Copy link

growlnx commented Nov 18, 2018

Had the same issue. Fixed by setting env var for ELECTRON_TRASH=gio.

I had the same problem in my MANJARO, this worked for me too

@vmvwebworks
Copy link

someone checked this? https://askubuntu.com/questions/288513/cant-move-files-to-the-trash

@c-benko
Copy link

c-benko commented Mar 29, 2019

@vmvwebworks this solution worked for me. If atom won't let you throw things in the trash, it might be a permission issues.

I used

sudo chown -R "$USER" ~/.local/share/Trash

and now there is no issue.

@memeplex
Copy link

Shouldn't this be closed? Correctly setting an environment variable fixes it completely. Moreover, if you wanted this to be the default behavior, for the user disliking direct manipulation of the environment, it's an upstream issue in any case.

@wyqydsyq
Copy link
Author

wyqydsyq commented May 17, 2019

I don't think requiring users to set env vars so this functionality works on common operating systems is reasonable. If this extension is capable of returning an error when the current default value doesn't work, it should also be capable of attempting to set the env var suggested here automatically as a fallback. Additionally, the gvfs-trash package has clearly been deprecated in favour of gio, so realistically this extension should be updated to use the new de facto, otherwise Linux users will all start seeing this feature break as they upgrade their distros to newer versions using gio instead of gvfs-trash

@Songworks
Copy link

I'm having this issue since Atom 1.39.0, however it's the other way around for me.
Unfortunately I'm also on a Ubuntu 16.04 based distribution and can't install the necessary glib2.0 version which contains gio.
So for those of us who have this issues that way around, you can also use the env variable to use gvfs-trash again:
ELECTRON_TRASH=gvfs-trash atom

@vilian
Copy link

vilian commented Aug 2, 2019

ELECTRON_TRASH=gvfs-trash atom worked for me on ubuntu 16 and

Atom : 1.39.1
Electron: 3.1.10
Chrome : 66.0.3359.181
Node : 10.2.0

What would be a more long-term solution? (The other solutions did not work)

@zacwitte
Copy link

zacwitte commented Aug 23, 2019

Same issue. Since the recent atom upgrade running on ubuntu 16.04 it complains about missing gvfs-trash, even though the file does in fact exist. I used the ELECTRON_TRASH=gvfs-trash atom trick to fix it, but this feels like something electron needs to handle automatically. Can't expect people to research this and add the hack to their environment.

@dotnetspec
Copy link

Linux Mint 18.3 x64
Atom 1.43

I have noted all the comments above (which have been apt) and particularly tried/noted the ones detailed below:

It seems that gvfs updates and dropped gvfs-trash, instead we should use gio trash now?
Temp workaround is to create a script as a warpper:

sudo vim /usr/bin/gvfs-trash

Fill it with content:

#!/bin/bash
# GVFS updated and dropped gvfs-trash to gio, but Atom didn't update.
/usr/bin/gio trash "$@"

and then:

sudo chmod +x /usr/bin/gvfs-trash

I don't think requiring users to set env vars so this functionality works on common operating systems is reasonable. If this extension is capable of returning an error when the current default value doesn't work, it should also be capable of attempting to set the env var suggested here automatically as a fallback. Additionally, the gvfs-trash package has clearly been deprecated in favour of gio, so realistically this extension should be updated to use the new de facto, otherwise Linux users will all start seeing this feature break as they upgrade their distros to newer versions using gio instead of gvfs-trash

sudo chown -R "$USER" ~/.local/share/Trash

This issue has been surprisingly difficult to resolve.
Is there anything else I can try?

@wyqydsyq
Copy link
Author

This issue has been surprisingly difficult to resolve.
Is there anything else I can try?

Uninstall Atom and use VSCode instead

@luisbrandao
Copy link

Why this is STILL an issue?
The workaround stopped working for me.

@gaetanquentin
Copy link

ubuntu 19.10
atom (snap) 1.45.0
gvfs-trash is installed

editing files on a sshfs mount

trying to delete directory (move to trash) on a local filesystem (~/home/XX) : OK

trying to delete directory (move to trash) on a mount filesystem (sshfs): KO

The following file couldn't be moved to the trash. blahblah Is gvfs-trash installed?

outside atom:
strace -e trace=file gio trash MyFile

it finds the trash but...
lstat("/mnt/XX/ssh/myhome_elitebook/.Trash", {st_mode=S_IFDIR|0775, st_size=34, ...}) = 0
lstat("/mnt/XX/ssh/myhome_elitebook/.Trash-1008", {st_mode=S_IFDIR|0775, st_size=0, ...}) = 0
gio: file:///mnt/XX/ssh/myhome_elitebook/T%C3%A9l%C3%A9chargements/terraform-provider-libvirt-0.6.1+git.1578064534.db13b678.Ubuntu_18.04.amd64.tar.gz: Unable to find or create trash directory for MyFile

the pb seems to be gio

@kryptus36
Copy link

For any googlers looking:
I just ran into this on my Gentoo box.
export ELECTRON_TRASH=gio fixed it.

@aurovrata
Copy link

There is an other issue that hasn't been addressed here, if you are working from the default apache installation, /var/www/html/, then gvfs-trash will complain:

 >gvfs-trash /var/www/html/wp/wp-content/themes/twentyfifteen/js/test.js
This tool has been deprecated, use 'gio trash' instead.
See 'gio help trash' for more info.

gio: file:///var/www/html/wp/wp-content/themes/twentyfifteen/js/test.js: Trashing on system internal mounts is not supported

NOTE: Trashing on system internal mounts is not supported

so I created a new script for /usr/bin/gvfs-trash

#!/bin/bash
# GVFS updated and dropped gvfs-trash to gio, but Atom didn't update.
/bin/rm -f "$@"

Probably not the best idea, but given that gvfs-trash is deprecated, I am assuming it should be ok.
Now it works, along with setting the env,

export ELECTRON_TRASH=gvfs-trash atom

@kin-allan
Copy link

kin-allan commented Jul 13, 2021

I had the same issue and none of the solutions above had worked.
If you are like me that has your projects under /var/www/ atom will not be able to delete, aparently the delete action does not works under the filesystem mount, so I manage it doing the following:
Created a folder www under my user, moved the files there, and then created a sysmlink from /var/www/ to my home mounted
When the files are on the ~/www I am able to delete correctly. Hope it helps

@the0neWhoKnocks
Copy link

Seeing the same error when trying to delete a folder while running Atom via Flatpak on Arch Linux. I've tried

ELECTRON_TRASH=gio atom .
export ELECTRON_TRASH=gio && atom .
flatpak override --user --env="ELECTRON_TRASH=gio" io.atom.Atom

no luck with any of the above.

The odd thing is, I'm able to delete individual files within a folder.

Also, I'm using Flatpak because I use n for my Node version manager, otherwise the official/AUR installs cause issues due to Node conflicts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests