ipfs / kubo

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

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

Closed athulantonynp closed 5 months ago

athulantonynp commented 7 months 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.

aschmahmann commented 5 months ago

Android builds aren't officially supported, although if there any fixes / changes to support that are simple enough we're happy to take them (this particular issue doesn't seem particularly actionable). Looking at what gomobile-ipfs is doing or leveraging the underlying libraries from boxo seems like the best bet.

You may have better luck asking on the forums http://discuss.ipfs.tech/ or chat channels https://docs.ipfs.tech/community/#chat.

openpokergame commented 4 months ago

I've encountered this as well, how do I solve this problem?

fengzie commented 3 months ago

The same issue happened here on Android.

core/builder.go:158 constructing the node: could not build arguments for function "reflect".makeFuncStub (/Users/mingfeng/sdk/go1.23.0/src/reflect/asm_arm64.s:29): failed to build pin.Pinner: could not build arguments for function "github.com/ipfs/kubo/core/node".Pinning (/Users/mingfeng/go/pkg/mod/github.com/ipfs/kubo@v0.29.0/core/node/core.go:45): failed to build format.DAGService: could not build arguments for function "github.com/ipfs/kubo/core/node".Dag (/Users/mingfeng/go/pkg/mod/github.com/ipfs/kubo@v0.29.0/core/node/core.go:144): failed to build blockservice.BlockService: could not build arguments for function "github.com/ipfs-shipyard/nopfs/ipfs".WrapBlockService (/Users/mingfeng/go/pkg/mod/github.com/ipfs-shipyard/nopfs/ipfs@v0.13.2-0.20231027223058-cde3b5ba964c/blockservice.go:24): failed to build *nopfs.Blocker: received non-nil error from function "github.com/ipfs/kubo/plugin/plugins/nopfs".MakeBlocker (/Users/mingfeng/go/pkg/mod/github.com/ipfs/kubo@v0.29.0/plugin/plugins/nopfs/nopfs.go:40): exec: "getent": executable file not found in $PATH