Description
Is your feature request related to a problem? Please describe.
Package management tools such as Go Modules and Rust Cargo use Write/Read Lock of File System. This is an important mechanism for removing conflicts.
The WSL2 shared directory \\wsl$
does not seem to support LockFileEx syscall. I confirmed that smb supports it. It returns an Incorrect function.
error with the LOCKFILE_EXCLUSIVE_LOCK
flag both set/unset.
To solve this problem, Rust Cargo has added code that ignores lock errors. rust-lang/cargo#7602
Go Modules does not work with WSL and officially replied to Issue that WSL is not supported. golang/go#37461
Describe the solution you'd like
Add locking functionality to the shared file system for a better development experience.
Describe alternatives you've considered
- Added logic to ignore lock errors in package management tools.
- Launch samba server on WSL2.
Additional context
Below is an example of an error with go modules in latest version.
> go mod download # go version 1.14
go: RLock Z:\example\go.mod: Incorrect function.
simple test code to call LockFileEx
package main
import (
"os"
"fmt"
"golang.org/x/sys/windows"
)
const (
reserved = 0
allBytes = ^uint32(0)
)
func main () {
f, err := os.Open("tmp.txt")
if err != nil {
panic(err)
}
lockType := uint32(2) // 0: readlock 2: writelock
ol := new(windows.Overlapped)
err = windows.LockFileEx(windows.Handle(f.Fd()), lockType, reserved, allBytes, allBytes, ol)
if err != nil {
panic(err)
}
fmt.Printf("success lock")
}