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

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

some error with the 'ln' scripts

问题

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

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

脚本内容如下:

  1. #!/bin/sh -e
  2. if [ ! -h gopath/src/github.com/coreos/etcd ]; then
  3. mkdir -p gopath/src/github.com/coreos/
  4. ln -s ../../../.. gopath/src/github.com/coreos/etcd
  5. fi
  6. export GOBIN=${PWD}/bin
  7. export GOPATH=${PWD}/gopath
  8. export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
  9. # 不要偷偷格式化用户的代码
  10. if [ "--fmt" = "$1" ]; then
  11. gofmt -s -w -l $GOFMTPATH
  12. fi
  13. go install github.com/coreos/etcd
  14. go install github.com/coreos/etcd/bench

一些补充信息:
我的系统是Windows 7
我在Git Bash上运行这个脚本。
问题重现步骤:

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

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

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

when exec the build shell
and the content is:

  1. #!/bin/sh -e
  2. if [ ! -h gopath/src/github.com/coreos/etcd ]; then
  3. mkdir -p gopath/src/github.com/coreos/
  4. ln -s ../../../.. gopath/src/github.com/coreos/etcd
  5. fi
  6. export GOBIN=${PWD}/bin
  7. export GOPATH=${PWD}/gopath
  8. export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
  9. # Don't surprise user by formatting their codes by stealth
  10. if [ "--fmt" = "$1" ]; then
  11. gofmt -s -w -l $GOFMTPATH
  12. fi
  13. go install github.com/coreos/etcd
  14. go install github.com/coreos/etcd/bench

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

  1. step1: open the git bash
  2. step2: git clone git@github.com:coreos/etcd.git
  3. step3: cd etcd
  4. 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/(如果没有这样的路径,你必须创建它)。然后输入以下命令:

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

接下来,你应该编辑构建脚本,删除创建符号链接和目录的行。例如:

  1. #!/bin/sh -e
  2. export GOBIN=${PWD}/bin
  3. export GOPATH=${PWD}/gopath
  4. export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
  5. # 不要偷偷格式化用户的代码
  6. if [ "--fmt" = "$1" ]; then
  7. gofmt -s -w -l $GOFMTPATH
  8. fi
  9. go install github.com/coreos/etcd
  10. 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

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

  1. #!/bin/sh -e
  2. export GOBIN=${PWD}/bin
  3. export GOPATH=${PWD}/gopath
  4. export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
  5. # Don't surprise user by formatting their codes by stealth
  6. if [ "--fmt" = "$1" ]; then
  7. gofmt -s -w -l $GOFMTPATH
  8. fi
  9. go install github.com/coreos/etcd
  10. 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上,执行以下命令:

  1. Microsoft Windows [版本 6.1.7601]
  2. C:\>set gopath
  3. GOPATH=C:\gopath
  4. C:\>go version
  5. go version go1.3 windows/amd64
  6. C:\>go get -v -u github.com/coreos/etcd
  7. github.com/coreos/etcd (下载)
  8. github.com/coreos/etcd/third_party/bitbucket.org/kardianos/osext
  9. github.com/coreos/etcd/pkg/strings
  10. github.com/coreos/etcd/error
  11. github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd
  12. github.com/coreos/etcd/http
  13. github.com/coreos/etcd/third_party/github.com/coreos/go-log/log
  14. github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics
  15. github.com/coreos/etcd/mod/dashboard/resources
  16. github.com/coreos/etcd/log
  17. github.com/coreos/etcd/third_party/github.com/gorilla/context
  18. github.com/coreos/etcd/third_party/github.com/gorilla/mux
  19. github.com/coreos/etcd/mod/dashboard
  20. github.com/coreos/etcd/discovery
  21. github.com/coreos/etcd/pkg/btrfs
  22. github.com/coreos/etcd/pkg/http
  23. github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
  24. github.com/coreos/etcd/mod/leader/v2
  25. github.com/coreos/etcd/mod/lock/v2
  26. github.com/coreos/etcd/metrics
  27. github.com/coreos/etcd/third_party/github.com/mreiferson/go-httpclient
  28. github.com/coreos/etcd/mod
  29. github.com/coreos/etcd/third_party/github.com/BurntSushi/toml
  30. github.com/coreos/etcd/third_party/github.com/goraft/raft/protobuf
  31. github.com/coreos/etcd/third_party/github.com/goraft/raft
  32. github.com/coreos/etcd/store
  33. github.com/coreos/etcd/server/v1
  34. github.com/coreos/etcd/server/v2
  35. github.com/coreos/etcd/store/v2
  36. github.com/coreos/etcd/server
  37. github.com/coreos/etcd/config
  38. github.com/coreos/etcd/etcd
  39. github.com/coreos/etcd
  40. C:\>
英文:

You shouldn't be using git clone and the build sh script. Use the go get command. For example, on Windows 7,

  1. Microsoft Windows [Version 6.1.7601]
  2. C:\>set gopath
  3. GOPATH=C:\gopath
  4. C:\>go version
  5. go version go1.3 windows/amd64
  6. C:\>go get -v -u github.com/coreos/etcd
  7. github.com/coreos/etcd (download)
  8. github.com/coreos/etcd/third_party/bitbucket.org/kardianos/osext
  9. github.com/coreos/etcd/pkg/strings
  10. github.com/coreos/etcd/error
  11. github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd
  12. github.com/coreos/etcd/http
  13. github.com/coreos/etcd/third_party/github.com/coreos/go-log/log
  14. github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics
  15. github.com/coreos/etcd/mod/dashboard/resources
  16. github.com/coreos/etcd/log
  17. github.com/coreos/etcd/third_party/github.com/gorilla/context
  18. github.com/coreos/etcd/third_party/github.com/gorilla/mux
  19. github.com/coreos/etcd/mod/dashboard
  20. github.com/coreos/etcd/discovery
  21. github.com/coreos/etcd/pkg/btrfs
  22. github.com/coreos/etcd/pkg/http
  23. github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
  24. github.com/coreos/etcd/mod/leader/v2
  25. github.com/coreos/etcd/mod/lock/v2
  26. github.com/coreos/etcd/metrics
  27. github.com/coreos/etcd/third_party/github.com/mreiferson/go-httpclient
  28. github.com/coreos/etcd/mod
  29. github.com/coreos/etcd/third_party/github.com/BurntSushi/toml
  30. github.com/coreos/etcd/third_party/github.com/goraft/raft/protobuf
  31. github.com/coreos/etcd/third_party/github.com/goraft/raft
  32. github.com/coreos/etcd/store
  33. github.com/coreos/etcd/server/v1
  34. github.com/coreos/etcd/server/v2
  35. github.com/coreos/etcd/store/v2
  36. github.com/coreos/etcd/server
  37. github.com/coreos/etcd/config
  38. github.com/coreos/etcd/etcd
  39. github.com/coreos/etcd
  40. 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:

确定