What version of Go are you using (go version)?

$ go version
go version go1.17.1 android/arm64

Does this issue reproduce with the latest release?

No

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/data/data/com.termux/files/home/.cache/go-build"
GOENV="/data/data/com.termux/files/home/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="android"
GOINSECURE=""
GOMODCACHE="/data/data/com.termux/files/home/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="android"
GOPATH="/data/data/com.termux/files/home/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/data/data/com.termux/files/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/data/data/com.termux/files/usr/lib/go/pkg/tool/android_arm64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="gccgo"
AR="ar"
CC="aarch64-linux-android-clang"
CXX="aarch64-linux-android-clang++"
CGO_ENABLED="1"
GOMOD="/storage/8D8B-150E/Go/secure-api/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/data/data/com.termux/files/usr/tmp/go-build380772883=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I tired to create a module for my new golang project using go mod init github.com/ayush/secure-api

What did you expect to see?

I expected of successfully creation of module for my project.

What did you see instead?

Error I got: go: RLock /storage/8D8B-150E/Go/secure-api/go.mod: function not implemented

Comment From: shmsr

@ayush-dedhia25 I see a similar query of yours was already answered on StackOverflow and even by a member of a Go Team (@bcmills) and still you have opened an issue here.

Refer: https://stackoverflow.com/a/68728663/5821408

Comment From: bcmills

I explicitly mentioned the possibility of filing an issue on the SO answer:

If you can't configure the filesystem to support locking and it isn't practical for you to work within a different filesystem that does, please file an issue at https://golang.org/issue/new, and mention issue #37461 (which is closely related) in the issue description.

So I think it's fine to keep this issue open. Honestly, I think we should probably proceed without file-locking when the go.mod and go.sum files cannot be locked — they're less prone to race conditions than, say, the module cache (which must support file-locking because it is much harder to fix if it becomes corrupted, and is implicitly modified much more frequently).

Comment From: bcmills

Locking the go.mod and go.sum files also interferes with certain gopls behaviors (see #50971, #50840). (CC @findleyr, @hyangah)

Now that the go command defaults to -mod=readonly, I wonder if this file-locking has outlived its usefulness. Maybe we should stop using file-locking in the main module (and only use it within the module cache). (CC @matloob)

On the other hand, the locking errors that show up in the gopls tests are probably actual real/write races, and they can probably at least show up as corrupted diagnostics in actual use. 🤔

Comment From: ianlancetaylor

@bcmills @matloob This issue is marked for 1.19. Should it move to Backlog? Thanks.

Comment From: wauk

Just to add some informarion I had this issue rooted my tablet and now i can lock files.

Comment From: Mobi97213

go version go1.21.4 android/arm64 echo $TERMUX_VERSION 0.118.0 android version 11

Is there any outlook on fixing this? I can't not run "go mod tidy", "go get -u", "go work use .", etc without getting an an error: go: RLock go.mod: Function not implemented

Am I correct in the conclusion that even though golang is in the termux repository, and it can be installed, it actually can't be used to develop and run a .go file?

Comment From: ProxVirtualZone

Am I correct in the conclusion that even though golang is in the termux repository, and it can be installed, it actually can't be used to develop and run a .go file?

I have the same problem with termux(

Comment From: wasserholz

This issue occured also for a colleague in Windows WSL 2 with Ubuntu. Would love to see a solution or at least a work around.

Comment From: wauk

This issue occured also for a colleague in Windows WSL 2 with Ubuntu. Would love to see a solution or at least a work around.

Sometimes its just the user that does not have permissions. After I rooted a device that did not have access to lock files this problem went away

Comment From: ezamelczyk

Unfortunately not every device is rootable. A workaround would be nice.

Comment From: alexis-renard

Hey, I am facing the same issue on termux as well. I guess I have found a workaround for my usecase.

  • go : go version go1.21.6 android/arm64
  • tmux : 0.118.0

Running go mod tidy, go run . or go build . all result in the same issue : go: RLock go.mod: Function not implemented The path where I run these commands is : /storage/emulated/0/documents/...

// go.mod
module my-module-name

go 1.21.6

I wonder the same question as https://github.com/golang/go/issues/48572#issuecomment-1808166355 : should we just give up on trying running go with multiple packages on termux or is there a way ?

EDIT: I have found a workaround for my usecase that has some limits

  • Usecase : I own and maintain the code, which is a little script relatively simple over which I have total control.
  • Workaround : The solution was to force go not to check the mod.go running export GO111MODULE=off on termux before the go execution. That also has made me refactor a bit the code to use only my main package / modifying the $GOPATH value for the other local packages to be foundable by go.
  • Limits : The workaround will surely not be sufficient for more complex code that require using not only one package / other usecases where the user doesn't have complete control over the code.

I hope to find something better soon, but posting it here if that would unblock some other users :)

Comment From: 0dminnimda

For

$ go version
go version go1.23.1 android/arm64
$ echo $TERMUX_VERSION
0.118.1

The message is

$ go mod init example.com/name
go: creating new go.mod: module example.com/name
go: updating go.mod: Lock /storage/emulated/0/Work/example/go.mod: function not implemented

It only creates an empty go.mod file.

Comment From: turbolent

This is also a problem for Go on WASI. Building Go for wasi1p/wasm seems to succeed, but then (with wasmtime): go: RLock go.mod: unsupported operation

Is there any way to disable file locking?