有人熟悉etcd项目吗? 或者我们最好在谈论此问题时忘记该项目。 问题是
$ build
ln: `gopath/src/github.com/coreos/etcd': cannot overwrite directory
当执行构建外壳时
内容是:
#!/bin/sh -e
if [ ! -h gopath/src/github.com/coreos/etcd ]; then
mkdir -p gopath/src/github.com/coreos/
ln -s ../../../.. gopath/src/github.com/coreos/etcd
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if ["--fmt" ="$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
一些补充:
我的系统是Windows 7
我在git bash上运行shell。
问题重现:
step1: open the git bash
step2: git clone git@github.com:coreos/etcd.git
step3: cd etcd
step4: build
我在这里看不到java的相关性。 我已经将其删除。
奇怪,我什至不能用ln -s发出这样的错误。
好的,告诉我:如果使用构建脚本转到目录,然后发出命令mkdir -p gopathsrcgithub.comcoreos和ln -s ........ gopathsrcgithub.comcoreosetcd-错误出现了吗?
@ Hi-Angel您能看一下我的编辑吗?
这是解决方案。 但这是一种解决方法,但是由于您使用的是Windows,所以我看不到其他方法。
启动命令行,然后在其中输入包含脚本的目录。 应该有一个路径gopath/src/github.com/coreos/(如果没有这样的路径,则必须创建它)。 接下来发出命令
mklink /D"gopath/src/github.com/coreos/etcd""../../../../"
接下来,您应该编辑构建脚本,以删除带有创建符号链接和目录的行。 例如。
#!/bin/sh -e
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if ["--fmt" ="$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
注意,我只是删除了4行代码。 接下来,您运行脚本,这应该可以工作。
当执行D: Git etcd> mklink D gopath / src / github.com / coreos / etcd ../../../ ..时,它说" unavailable switch-src"
@ user3231931,哦,对不起,我写了错误的斜线。它应该是mklink D gopathsrcgithub.comcoreosetcd ........。我将编辑答案。
我已经尝试过了。同样的结果是" unavailable switch-src"的接线。
@ user3231931 hm ...然后尝试添加引号,例如:mklink D"gopathsrcgithub.comcoreosetcd""........"
是的,现在通过添加引号可以工作。我尝试其他部分。
我相应地编辑了答案。
好的解决方法,比我首先提到该问题的答案更为详细。 +1
@ Hi-Angel sign。删除if [ ! -h gopathsrcgithub.comcoreosetcd ]; then mkdir -p gopathsrcgithub.comcoreos ln -s ........ gopathsrcgithub.comcoreosetcd fi无法加载包后执行构建外壳时的另一个问题:包github.com/coreos/etcd:open d: git etcd gopath src github.com coreos etcd:访问被拒绝。
@ user3231931我知道为什么会这样。 ........路径是指甚至在"磁盘D:"上方的不存在的目录。我认为该脚本可能应该在其中有其他一些相关的目录,并且我不知道该目录可能是什么。
@ user3231931这真的很奇怪。也许您应该在etcd的邮件列表或IRC上询问有关目录的信息。
@ Hi-Angel好的。我会在邮件列表中询问它,非常感谢
@VonC,如果您偶尔认为我看到了您的答案,并决定偷了它,那不是真的。我没有刷新页面,此刻也没有看到答案。我什至不知道ln的问题是什么,什么是etcd。在找出一些评论之后,我刚刚看到该脚本,表明使用Windows的作者和BASH可能是通过某些ln失败的模拟解释器执行的,并回想起Windows对symlink的支持。然后用谷歌搜索创建这些的命令,并且-瞧。
@ Hi-Angel这种想法永远不会消失。我仍然认为您的回答比我的回答更好,更完整,并且很高兴您抽出时间来进一步调查该问题。
如" Git Bash Shell无法创建符号链接"中所述(因为您在Windows 7的git bash中使用脚本)
the ln that shipped with msysGit simply tries to copy its arguments, rather than fiddle with links. This is because links only work (sort of) on NTFS filesystems, and the MSYS team didn't want to reimplement ln.
A workaround is to run mklink from Bash.
This also allows you to create either a Symlink or a Junction.
因此,默认情况下,在Windows的Git附带的旧外壳中," ln"将无法正常工作。
您不应该使用git clone和build sh脚本。 使用go get命令。 例如,在Windows 7上,
Microsoft Windows [Version 6.1.7601]
C:\>set gopath
GOPATH=C:\gopath
C:\>go version
go version go1.3 windows/amd64
C:\>go get -v -u github.com/coreos/etcd
github.com/coreos/etcd (download)
github.com/coreos/etcd/third_party/bitbucket.org/kardianos/osext
github.com/coreos/etcd/pkg/strings
github.com/coreos/etcd/error
github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd
github.com/coreos/etcd/http
github.com/coreos/etcd/third_party/github.com/coreos/go-log/log
github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics
github.com/coreos/etcd/mod/dashboard/resources
github.com/coreos/etcd/log
github.com/coreos/etcd/third_party/github.com/gorilla/context
github.com/coreos/etcd/third_party/github.com/gorilla/mux
github.com/coreos/etcd/mod/dashboard
github.com/coreos/etcd/discovery
github.com/coreos/etcd/pkg/btrfs
github.com/coreos/etcd/pkg/http
github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
github.com/coreos/etcd/mod/leader/v2
github.com/coreos/etcd/mod/lock/v2
github.com/coreos/etcd/metrics
github.com/coreos/etcd/third_party/github.com/mreiferson/go-httpclient
github.com/coreos/etcd/mod
github.com/coreos/etcd/third_party/github.com/BurntSushi/toml
github.com/coreos/etcd/third_party/github.com/goraft/raft/protobuf
github.com/coreos/etcd/third_party/github.com/goraft/raft
github.com/coreos/etcd/store
github.com/coreos/etcd/server/v1
github.com/coreos/etcd/server/v2
github.com/coreos/etcd/store/v2
github.com/coreos/etcd/server
github.com/coreos/etcd/config
github.com/coreos/etcd/etcd
github.com/coreos/etcd
C:\>
这两种方式有什么区别?
@ user3231931:是的。像go get这样的Go工具可以毫不费力地为您解决这一问题。您使用了依赖于软件包和依赖于操作系统的构建脚本的软糖,该脚本当前在一个操作系统上适用于一个软件包,而在其他操作系统上则不起作用。 Go软件包不需要构建脚本。