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

could you replace file.access with R.utils::fileAccess ? #49

Closed
stla opened this issue Nov 11, 2016 · 9 comments
Closed

could you replace file.access with R.utils::fileAccess ? #49

stla opened this issue Nov 11, 2016 · 9 comments

Comments

@stla
Copy link

stla commented Nov 11, 2016

Hello,

This is a message for the author of the digest package.

It is known that file.access has some issues with network drives, as we can see in this issue and in this post on stackoverflow.

I am the author of this post on stackoverflow. I get:

> file.access("U:/Data", 4)
U:/Data 
     -1 

I have tried the fileAccess function from the R.utils package:

> R.utils::fileAccess("U:/Data", 4)
[1] 0
Warning message:
In fileAccess.default("U:/Data", 4) :
  file.access(..., mode=4) and file(..., open="rb")+readBin() gives different results (-1 != 0). Will use the file()+readBin() results: U:/Data

This time, I get 0.
Thus, my problem (and perhaps other problems) would be solved if you replaced file.access with R.utils::fileAccess.

@eddelbuettel
Copy link
Owner

eddelbuettel commented Nov 11, 2016

No, I can't / won't because it would add another dependency needed only by

  • a subset of OSs
  • a subset of users with wrongly configured network drives
    and proliferation of dependencies is generally not a desirable thing. Rest assured that millions of users get digest to work faithfully for them, including on Windows. And network drives.

Now, if you really must change the code and cannot change your directory, then I would consider a really careful pull request against digest which branches the execution and possibly doubles the code from R.utils. @HenrikBengtsson is already a contributor and co-author and won't mind (I surmise...)

Edit: And I should add that file-based use is yet again a subset of users. You can help yourself NOW by adding a local version of digest which copies the file to C:/TEMP (or alike), then calls digest::digest on it and removes the temp copy.

@stla
Copy link
Author

stla commented Nov 11, 2016

Ok, thank you for your attention and your reply.
I find very strange that file.access returns -1 whereas the folder is readable. Could one consider that this is a bug of the function file.access ? In this case, this would be a bug to be reported to the R Core Team (https://www.r-project.org/bugs.html). But maybe I misunderstand something and the returned value -1 is the right value to be returned....

@stla
Copy link
Author

stla commented Nov 11, 2016

users with wrongly configured network drives

Indeed, this is possibly a wrong configuration... I'll try to talk about that to the IT team of my company but I'm afraid it will be hard to explain ^^

@stla
Copy link
Author

stla commented Nov 12, 2016

I've found a workaround.

mydigest <- function (object, algo = c("md5", "sha1", "crc32", "sha256", 
    "sha512", "xxhash32", "xxhash64", "murmur32"), serialize = TRUE, 
    file = FALSE, length = Inf, skip = "auto", ascii = FALSE, 
    raw = FALSE, seed = 0, errormode = c("stop", "warn", "silent")) 
{
  file.access <- R.utils::fileAccess
  .... the code of the digest function here ...
}

Then:

library(R.utils)
library(roxygen2)
library(digest)
reassignInPackage("digest", "digest", mydigest)

And now I can do roxygenize() and it works.

@HenrikBengtsson
Copy link
Contributor

A few comments (also for future readers if they find this thread):

I don't know whether it as simple as "a subset of users with wrongly configured network drives" or not. I first discovered this issue on Windows back in 2008 and I believe I saw it with other setups too. I'm pretty sure I did lots of troubleshooting trying to figure out what was going on, but never found a solution other than all the fallback tests that R.utils::fileAccess() implements. BDR replied to my R-devel thread ['file.access() on network (mounted) drive on Windows Vista?']((https://stat.ethz.ch/pipermail/r-devel/2008-December/051461.html) that they've seen this too for cross-platform mounted file systems.

I agree with Dirk that it doesn't make sense to add dependencies to the digest package. I think it would be doable to port a cleaned up version of R.utils::fileAccess() that relies only on base R functions.

Even better would be to try to improve on base::file.access() itself. However, it could be tricky to convince an R core developer that this is worthwhile. But personally I would totally support it because it is unfortunate when users has to struggle with things like this, especially when it could be solved centrally.

@eddelbuettel
Copy link
Owner

eddelbuettel commented Nov 12, 2016

👍 on fixing it in R itself.

You know the problem, you know the fix, could you please quietly email Duncan M and quietly ask who (besides him) may be willing to look into this.

(And of course: I know you are busy too. We all are. But it won't get resolved until has sufficient motivation to carry it through....)

@stla
Copy link
Author

stla commented Nov 12, 2016

But personally I would totally support it

It's also quite possible that the RStudio team would totally support it. I say that because:

  1. I got some similar "readability" problems caused by file.access when I installed a portable version of RStudio on my "network drive".
  2. When I used Google to search the cause of my readability problem, I found several reports of this problem by some guys who tried to install RStudio on a "network drive".

@eddelbuettel
Copy link
Owner

eddelbuettel commented Nov 12, 2016

@stla: You are not adding value to the discussion. RStudio has the exact same options as you and me for getting code into base R: none, besides persuading an R Core member to commit it.

For the rest, you are basically repeating over and over that "there can be issues with Windows and a network drive". Which has zero to do with the digest package here.

@stla
Copy link
Author

stla commented Nov 13, 2016

RStudio has the exact same options as you and me for getting code into base R: none, besides persuading an R Core member to commit it.

This is precisely why I said that RStudio would also support this request to the R Core team....

And I had zero intention to repeat anything.

Maybe you misunderstood my previous comment, or inversely this is me who misunderstood something. But anyway I don't think I deserved such a contemptuous reply. Perhaps I made you angry because I used your Github repo to discuss about a point which is not related to the digest package. I apologize for that.

Repository owner locked and limited conversation to collaborators Nov 13, 2016
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

3 participants