ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
15.81k stars 2.96k forks source link

Creating node in Android with gomobile & kubo is failing by saying `GETENT` is not found in path #10407

Open athulantonynp opened 2 weeks ago

athulantonynp commented 2 weeks ago

Checklist

Installation method

third-party binary

Version

No response

Config

No response

Description

Disclaimer: I am fairly new to Golang and IPFS world. I am trying to run kubo with the help of gomobile in an Android app. The process of creating a node is failing with long error saying

constructing the node: could not build arguments for function "github.com/ipfs/kubo/core/node".PeerWith.func1 (/Users/apple/go/pkg/mod/github.com/ipfs/kubo@v0.27.0/core/node/peering.go:30):
 failed to build *peering.PeeringService: could not build arguments for function "github.com/ipfs/kubo/core/node".Peering (/Users/apple/go/pkg/mod/github.com/ipfs/kubo@v0.27.0/core/node/peering.go:14):
 failed to build host.Host: could not build arguments for function "github.com/ipfs/kubo/core/node/libp2p".Host (/Users/apple/go/pkg/mod/github.com/ipfs/kubo@v0.27.0/core/node/libp2p/host.go:40):
 could not build value group []config.Option[group="libp2p"]: received non-nil error from function "github.com/ipfs/kubo/core/node".LibP2P.ResourceManager.func9 (/Users/apple/go/pkg/mod/github.com/ipfs/kubo@v0.27.0/core/node/libp2p/rcmgr.go:32)
: opening IPFS_PATH: exec: "getent": executable file not found in $PATH

What i understood from the error is that the ipfs core package is trying to access GETENT program from the underlying linux arch which is restricted on non-rooted devices. But i am struggling to solve this.

I have created a minimal reproducible example in this repo https://github.com/athulantonynp/ipfs-android-golang with the build instructions.

Also here is my go env output.

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/apple/Library/Caches/go-build'
GOENV='/Users/apple/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/apple/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/apple/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/_3/pglmczx934d_qc7zs9r0dz_w0000gn/T/go-build2297058153=/tmp/go-build -gno-record-gcc-switches -fno-common'

Any leads to solve this issue appreciated.

PS: I have seen some other repos like https://github.com/ipfs-shipyard/gomobile-ipfs and it is working fine even though their approach to create the nodes are similar except the Golang & Kubo versions are bit old compared to what i have used. I guess it shouldn't be a problem.