-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
path/filepath: EvalSymlinks of container mapped directory returns an error #23512
Comments
/cc @alexbrainman |
Thank you for the report. I will investigate this when I have time. Alex |
Thanks @alexbrainman let me know if I can provide any additional info. |
I did a little more investigating. This following program also fails: package main
import "os"
import "fmt"
func main() {
path, err := os.Readlink("C:\\host")
if err != nil {
panic(fmt.Errorf("os.Readlink failed: %v", err))
}
println("readlink path", path)
fi, err := os.Open(path)
if err != nil {
panic(fmt.Errorf("os.Open failed: %v", err))
}
defer fi.Close()
println("file info", fi.Name())
}
However if I prepend package main
import "os"
import "fmt"
func main() {
path, err := os.Readlink("C:\\host")
if err != nil {
panic(fmt.Errorf("os.Readlink failed: %v", err))
}
println("readlink path", path)
fi, err := os.Open("\\\\?" + path)
if err != nil {
panic(fmt.Errorf("os.Open failed: %v", err))
}
defer fi.Close()
println("file info", fi.Name())
}
Is is possible that |
I just need to be able to reproduce your problem, and I will need Docker installed for that. What is the easiest way to install Docker if I have Windows 10? You can also try and fix this yourself. If you try, you need to be aware about forthcoming change https://go-review.googlesource.com/#/c/go/+/86556/ that might affect your problem. Also Windows paths starting with \?\ are not handled very well in many Go standard library parts. For example path/filepath does not handle these paths at all. Also see issue #22230.
os.Readlink is broken on Windows. os.Readlink current implementation does not work in many situations, and I do not know of a way to implement it properly. But lets not discuss os.Readlink here. Create new issue for os.Readlink, if you think it is important. Alex |
@alexbrainman you can install Docker for Windows 10 by following the instructions here. You will want to make sure that you switch to Windows Containers (the second step). I'll see if I can spend some time looking at this as well. |
When I run "Docker for Windows" app, I get this message but I do not want to proceed, because I do use VirtualBox. I do not want to loose ability to run VirtualBox. What should I do? Thank you. Alex |
It is specifically the hardware virtualization extensions that will not work; Hyper-V acquires them before Windows boots and Virtualbox can't use them anymore. This can be restored by disabling the hyper-v service in I happen to have Docker Enterprise on a W10 system and can attempt to reproduce it if that workaround isn't possible |
I discovered that much myself.
I will try https://cloud.google.com/compute/docs/containers/#docker_on_windows when I have time. Alex |
@alexbrainman the link above should work on Windows Server 2016, without the need to disable Virtualbox. |
If you are referring to https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10 then it does not help me, because I only have Windows 10 computer, not Windows Server 2016, If you are referring to https://cloud.google.com/compute/docs/containers/#docker_on_windows then yes, it should work. But I would need to create computer from scratch and install all the tools I need. So I will need some free time. Alex |
@kolyshkin I can confirm that this is still an issue. Running |
@tescherm I am not surprised that os.Readlink is broken on windows. But maybe path/filepath.EvalSymlinks is OK. Please, try this program instead package main
import (
"fmt"
"path/filepath"
)
func main() {
path, err := filepath.EvalSymlinks("c:\\host")
if err != nil {
panic(err)
}
fmt.Printf("eval path: %s\n", path)
} If it still fails, someone would have to investigate where it fails. I still do not have Windows Docker installed on my computer - I use VirtualBox, and, apparently, you cannot have both. So I would need to configure new PC somewhere (probably in the cloud), and have Go development environment installed on it before I can even start investigating this. I have very little free time nowadays, but I will do that, if nothing else. Thank you. Alex |
@alexbrainman I tried it out, unfortunately the program also fails on 1.11:
|
@tescherm thanks for checking. I would have to debug this myself when I have time. Alex |
I managed to setup appropriate environment for your test. I build this program package main
import (
"fmt"
"path/filepath"
)
func main() {
path, err := filepath.EvalSymlinks("c:\\host")
if err != nil {
panic(err)
}
fmt.Printf("eval path: %s\n", path)
} and copied resulting exe into c:\test.exe, and then run this command
I can reproduce your error now. Looking at the code, we call Windows API GetFinalPathNameByHandle with If we adjust this code to return path/filepath.EvalSymlinks is started as code to follow symlinks on Unix. I am not sure what we have here is covered by that description. Thank you. Alex |
@alexbrainman great, yes, I believe that returning package main
import "os"
import "fmt"
func main() {
path, err := filepath.EvalSymlinks("c:\\host")
if err != nil {
panic(err)
}
fmt.Printf("eval path: %s\n", path)
// open resolves correctly
fi, err := os.Open(path)
if err != nil {
panic(fmt.Errorf("os.Open failed: %v", err))
}
defer fi.Close()
println("file info", fi.Name())
} Thanks again for drilling in. |
If we return The And, in #23512 (comment) , you did not explain why you need to to call filepath.EvalSymlinks? Why cannot you call os.Open("c:\host") instead? Alex |
Note that |
I agree. https://golang.org/cl/121676 is unrelated to this issue. It is still not clear to me what Alex |
What version of Go are you using (
go version
)?go version go1.9.2 windows/amd64
andgo version go1.10beta2 windows/amd64
.Does this issue reproduce with the latest release?
Yes, this is reproducable with go
1.10beta2
and1.9.2
What operating system and processor architecture are you using (
go env
)?What did you do?
Running
filepath.EvalSymlinks
against a bind mounted directory within a windows container (for example,\\?\ContainerMappedDirectories\D48AFB19-F38F-4DAE-A698-4D718D506B15
) returns the following error:eval_symlinks.go
above is the following program:Note that the symlink is valid. For example, I can
cd
to it:golang 1.9.2 returns the same error:
I see that EvalSymlinks on Windows was reimplemented recently (66c03d3), maybe there was a nuance wrt the
\\?\
path style that was missed?What did you expect to see?
I expected
filepath.EvalSymlinks
to return the original directory (C:\host
) or the directory that was linked to (\\?\ContainerMappedDirectories\007C5A5F-50A3-4019-BCF1-1BA20F4745
).What did you see instead?
The error
GetFileAttributesEx \ContainerMappedDirectories: The system cannot find the file specified
.The text was updated successfully, but these errors were encountered: