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

Access denied to .solution.json on Windows #557

Closed
FabienTregan opened this issue Jun 18, 2018 · 4 comments
Closed

Access denied to .solution.json on Windows #557

FabienTregan opened this issue Jun 18, 2018 · 4 comments

Comments

@FabienTregan
Copy link
Contributor

FabienTregan commented Jun 18, 2018

Environement

  • Windows command line (cmd.exe)
  • Latest exercism build (from nextercism branch)
  • Empty workspace

Observed behaviour

If you try to download an exercism twice, the second time it will fail because with an access denied. Submiting also gives the same error 👍

D:\code\Exercism>v2 download hello-world --track=rust

D:\code\Exercism>v2 download hello-world --track=rust
Error: open D:\code\Exercism\workspace\rust\hello-world\.solution.json: Access is denied.

The problem probably occures anytime the .solution file is modified.

#Expected behaviour

Just working :)

#Analysis

Possible solutions

Since I could not find a way to write to hidden files on windows with go, two possible solutions come to me:

  • avoid hiding the file
  • delete the file before writting it
@FabienTregan FabienTregan changed the title Acces denied to .solution.json on Windows Access denied to .solution.json on Windows Jun 18, 2018
@FabienTregan
Copy link
Contributor Author

Is seems that this one won't be easily fixed. We would have to use a modified implemtation of the file write / open functions that would pass proper attributes to syscall on windows (see golang/go#25923 (comment) )

While possible, less tricky solutions could be :

  • not hiding the file on windows
  • delete the file before writing it, then making it invisible (I dont think we appen anything to the file ?)
  • make the file visible, write to it, re-hide it

@kytrinyx
Copy link
Member

I'm kind of OK with not hiding the file, to be honest.

Another thing we could consider is to only try to write it if it's different from what's there, in which case we could delete and rewrite (for all platforms).

@nywilken
Copy link
Contributor

nywilken commented Jul 14, 2018

@FabienTregan I am unable to reproduce this issue on Windows following the steps you called out above.
Looking at PR #630 I see that test are failing diving in a little deeper if I remove the calls to visibility.Hidefile all the tests pass.

I need to dive deeper into the issue and visibility package to get a better understanding of what is going on. Is this a limitation of Windows with dot files? I used them, but only ever modify via cli without issue.

Does this issue have anything to do with UAC on Windows levels?

@FabienTregan
Copy link
Contributor Author

Te issue is currently workedaround by th following lines :

// Hack because ioutil.WriteFile fails on hidden files
visibility.ShowFile(path)
if err := ioutil.WriteFile(path, b, os.FileMode(0600)); err != nil {
return err
}
s.Dir = dir
return visibility.HideFile(path)

It seems possible that PR #630 allows us to delete those two lines.

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

No branches or pull requests

3 participants