有关’ln’脚本的一些错误。

huangapple go评论88阅读模式
英文:

some error with the 'ln' scripts

问题

有人熟悉etcd项目吗?或者在讨论这个问题时最好忘记这个项目。问题是在执行build脚本时出现以下错误:

ln: `gopath/src/github.com/coreos/etcd': 无法覆盖目录

脚本内容如下:

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

# 不要偷偷格式化用户的代码
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上运行这个脚本。
问题重现步骤:

步骤1:打开Git Bash
步骤2:git clone git@github.com:coreos/etcd.git
步骤3:cd etcd
步骤4:build
英文:

anybody is familiar with the etcd project? Or we'd better forget the project when talk about this issue. The issue is

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

when exec the build shell
and the content is:

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

Some addition:
My system is windows 7
I run the shell on git bash.
issue reproduce:

step1: open the git bash
step2: git clone git@github.com:coreos/etcd.git
step3: cd etcd
step4: build

答案1

得分: 1

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

> msysGit附带的ln命令只是尝试复制其参数,而不是处理链接。这是因为链接只在NTFS文件系统上(某种程度上)起作用,而MSYS团队不想重新实现ln。
>
> 一个解决方法是从Bash中运行mklink命令。
这还允许您创建符号链接或联接

因此,默认情况下,在Git for Windows附带的旧shell中,ln命令无法按预期工作。

英文:

As mentioned in "Git Bash Shell fails to create symbolic links" (since you are using the script in a git bash on Windows 7)

> 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.

So 'ln' wouldn't work as expected by default, in the old shell that ships with Git for Windows.

答案2

得分: 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"

# 不要偷偷格式化用户的代码
if [ "--fmt" = "$1" ]; then
    gofmt -s -w -l $GOFMTPATH
fi

go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench

注意,我只删除了4行代码。然后运行脚本,应该可以正常工作。

英文:

Here's solution. Tbh it is a workaround, but since you're on Windows, I don't see another way.

Start a command line, and enter there to the directory with the script. There should be a path gopath/src/github.com/coreos/ (if no such a path, you must create it). Next issue a command

mklink /D "gopath/src/github.com/coreos/etcd" "../../../../"

Next you should edit the build script to delete a lines with creation symlink and a directory. E.g.

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

Note, that I am just removed 4 lines of code. Next you run the script, and this should work.

答案3

得分: 0

你不应该使用git clonebuildsh脚本,而应该使用go get命令。例如,在Windows 7上,执行以下命令:

Microsoft Windows [版本 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 (下载)
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:\>
英文:

You shouldn't be using git clone and the build sh script. Use the go get command. For example, on 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:\>

huangapple
  • 本文由 发表于 2014年8月20日 11:59:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/25396511.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定