mongodb - 从源代码安装 Mongo 工具
问题描述
我正在安装 MongoDB,我需要 mongoimport。我已经从源MongoDB安装了 MongoDB 本身。我仍然需要mongoimport,它是mongo-tools mongo-tools github的一部分。其中说明了一些说明,我已经克隆了存储库,进入它(/ssd/[MYNAME]/mongoinstall/mongo-tools)并运行
. ./set_goenv.sh
回购状态的自述文件可以运行. ./set_gopath.sh
,但这个不存在。
虽然我不觉得该命令做了任何事情,因为
go env
没有改变。
我也从源代码安装了 GO。
go build -o bin/mongoimport mongoimport/main/mongoimport.go
返回以下错误:
mongoimport/main/mongoimport.go:13:2: cannot find package "github.com/mongodb/mongo-tools-common/log" in any of:
/ssd/[MYNAME]/mongoinstall/go/src/github.com/mongodb/mongo-tools-common/log (from $GOROOT)
/export/scratch1/home/gast141/go/src/github.com/mongodb/mongo-tools-common/log (from $GOPATH)
mongoimport/main/mongoimport.go:14:2: cannot find package "github.com/mongodb/mongo-tools-common/signals" in any of:
/ssd/[MYNAME]/mongoinstall/go/src/github.com/mongodb/mongo-tools-common/signals (from $GOROOT)
/export/scratch1/home/gast141/go/src/github.com/mongodb/mongo-tools-common/signals (from $GOPATH)
mongoimport/main/mongoimport.go:15:2: cannot find package "github.com/mongodb/mongo-tools-common/util" in any of:
/ssd/[MYNAME]/mongoinstall/go/src/github.com/mongodb/mongo-tools-common/util (from $GOROOT)
/export/scratch1/home/gast141/go/src/github.com/mongodb/mongo-tools-common/util (from $GOPATH)
mongoimport/main/mongoimport.go:16:2: cannot find package "github.com/mongodb/mongo-tools/mongoimport" in any of:
/ssd/[MYNAME]/mongoinstall/go/src/github.com/mongodb/mongo-tools/mongoimport (from $GOROOT)
/export/scratch1/home/gast141/go/src/github.com/mongodb/mongo-tools/mongoimport (from $GOPATH)
我努力了
./build.sh
但它惊呼:
GOROOT not set and preferred GOROOT '/ssd/[MYNAME]/mongoinstall/go/bin/go' doesn't exist. Aborting.
的输出go env
是:
GOARCH="amd64"
GOBIN=""
GOCACHE="/export/scratch1/home/gast141/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/export/scratch1/home/gast141/go"
GOPROXY=""
GORACE=""
GOROOT="/ssd/[MYNAME]/mongoinstall/go"
GOTMPDIR=""
GOTOOLDIR="/ssd/[MYNAME]/mongoinstall/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build916816613=/tmp/go-build -gno-record-gcc-switches"
我在Fedora release 28 (Twenty Eight)
我怎样才能让 mongoimport 工作?
解决方案
我在 Mac 系统上尝试编译 mongotools 时遇到了同样的错误。就我而言,问题是set_gopath.sh
(对于 mongotools 版本 3.6.5)与我使用的 shell 不兼容(fish
)。该脚本导出GOPATH
环境变量,但一旦回到环境中,它似乎不会保留其适当的变量fish
。
我尝试bash
在持久性 bash shell 中运行set_gopath.sh
,然后运行go build
命令,但结果是相同的问题。
我发现一个成功的解决方法是修改set_gopath.sh
并在最后包含go build
命令。运行set_gopath.sh
然后设置环境并成功运行 go 命令。
推荐阅读
- apache-camel - Camel SQL 存储过程语法格式
- python - JupyterHub 单用户无法通过 systemdspawner 使用 tensorflow gpu 支持
- opencl - rgb转nv12结果比较失败
- java - 铁路模拟的命令处理程序/解析器
- jenkins - Jenkins DSL - 掩码密码
- python - 我如何使用 Numpy 计算我的数组中有多少条目,例如给出 0,9 的累积总和?
- java - Xodus Java:找不到符号 PersistentEntityStores
- python - 使用python查找带有if条件的字符串
- azure - Microsoft Azure 人脸 API - 使用 Node-RED 进行人脸检测
- ocr - 在 windows 上训练 tesseract4.0 的过程