'ln'脚本有些错误

时间:2014-08-20 03:59:13

标签: linux windows shell go

有人熟悉etcd项目吗?或者我们在谈论这个问题时最好忘记这个项目。问题是

$ build
ln: `gopath/src/github.com/coreos/etcd': cannot overwrite directory

执行构建 shell时 内容是:

#!/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

3 个答案:

答案 0 :(得分:1)

如“Git Bash Shell fails to create symbolic links”中所述(因为您在Windows 7上使用git bash中的脚本)

  

msysGit附带的ln只是试图复制其参数,而不是乱用链接。这是因为链接仅在NTFS文件系统上工作(类型),并且MSYS团队不想重新实现ln。

     

解决方法是从Bash运行mklink   这也允许您创建Symlink or a Junction

所以'ln'默认情况下无法正常工作,在Git for Windows附带的旧shell中。

答案 1 :(得分:1)

这是解决方案。这是一种解决方法,但由于你是在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行代码。接下来,您运行脚本,这应该可以。

答案 2 :(得分:0)

您不应该使用git clonebuild 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:\>