cannot remove file, 'Permission denied'


Like Permissions issue, I'm having an issue where I can't run a command because R is unable to delete a temp file. I've tried changing the permissions within that folder in windows, updating R, and trying to run the same command with the file in a different location. Ultimately the goal here is to run the following code:

TaxIDs <- accessionToTaxa(Accession,'accessionTaxa.sql')

The error message I get when I run this is:

Error: no such table: accessionTaxa
Warning message:
In file.remove(tmp) :
cannot remove file 'C:\Users\Merlin\AppData\Local\Temp\RtmpkbYvsa\file4648647840ed', reason 'Permission denied'

Any suggestions are appreciated! Thanks so much.

I don't think it's a permission problem.

That seems to indicate that your input database 'accessionTaxa.sql' is not the correct one.

Did you run prepareDatabase('accessionTaxa.sql')? What was the output? You didn't change working directory since then? What is the result of file.exists('accessionTaxa.sql') ?

I might be missing something, as to me that is a problem in the function. If you check the source code, you can find these two lines:


so that means, when the function finishes, it will delete the temporary copy of the database, and disconnect from it. In that order. So it will always fail to delete the file, as the connection is still open. The correct code should use after = TRUE. So I kind of expect that you will always get this warning message, even when things work well (unless the connection happens to get closed for other reasons).

In any case, that doesn't seem to be the cause of your problem here.

Thanks! I reran prepareDatabase and noticed that it says it's completed at %100 but also says "Error in curl::curl_download(xx, yy, mode = "wb", quiet = FALSE) :
Timeout was reached: FTP response timeout".

So it just never finished compiling the database. I'm now making the database the 'manual' way, which has been working so far.

Great if you can get the manual method to work. But FYI, there may be ways around the problem.

First, the error suggests the timeout is on the FTP server side (NCBI's side), but know that curl also has an internal timeout that you can set as an option. Second, from your link, there is a protocol option that could allow you to try http instead of ftp, maybe NCBI has a different timeout there. Third, your link also mentions the possibility to "allow download resumption on interrupted downloads".

So if you're interested, these could be things to look into to get prepareDatabase() to work automatically, but you'd need to investigate a bit more.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.