Ruby命令与$gopath中的程序冲突。

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

Ruby commands conflicting with program in $gopath

问题

我以前在我的Mac上使用Homebrew安装了rbenv,并且安装了几个不同版本的Ruby。有一段时间我没有经常使用Ruby,并在我的计算机上安装了其他东西(包括OSX 10.9.3和Go)。今天我运行rbenv时,它一遍又一遍地重复显示以下消息:

tory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
^C

当我运行ruby -v时,它一遍又一遍地重复显示以下消息:

/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/Cellar/rbenv/0.4.0

我使用Homebrew卸载了rbenv并重新安装,但问题仍然存在。

当我运行jekyll serve -w(在本地运行jekyll博客)时,我也遇到了相同的错误:

/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory

更新:
我最近在我的计算机上安装了Go,并且今天运行了一些Go程序,其中一个叫做Head。似乎当我尝试运行rbenv或jekyll时收到的错误消息来自于我的$GOPATH中的一个Go脚本。这是HEAD脚本,它打印错误消息:

"Usage: ", os.Args[0], "host:port"

该程序位于$GOPATH中:

/Users/randomname/go/src/github.com/myname/head

我不明白为什么这会与Ruby命令冲突。

这是我的bash_profile文件。问题:这个文件中是否有导致冲突的内容?

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

export PGHOST=localhost


export LASTFM_API='76479e879457be34dd1180f78e731fc0'

export PATH=${PATH}:/usr/local/mysql/bin
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"

export GOPATH=/Users/randomname/go/
export PATH=$GOPATH/bin:$PATH

# The next line updates PATH for the Google Cloud SDK.
source '/Users/my_name/google-cloud-sdk/path.bash.inc'

# The next line enables bash completion for gcloud.
source '/Users/randomname/google-cloud-sdk/completion.bash.inc'

alias goapp=~/google-cloud-sdk/platform/google_appengine/goapp

export PATH=/path/to/go_appengine:$PATH
英文:

I had rbenv installed (with homebrew) and working on my mac with several versions of ruby in the past. For a period of time I didn't use Ruby very much and have installed other things (including OSX 10.9.3 and Go) on my computer. I ran rbenv today and it repeated this message over and over

tory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/bin/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
^C

When I run ruby -v it repeats this message over and over

/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory
/usr/local/Cellar/rbenv/0.4.0

I uninstalled rbenv with homebrew and reinstalled it but have the same problem.

When I run jekyll serve -w (to run a jekyll blog locally), I also get the error

/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: line 14: cd: Usage:  Head host:port: No such file or directory

Update
I have recently installed Go on my computer and ran a few Go programs today, one of which is called Head. It appears the error message that I'm getting when trying to run rbenv or jekyll is from one of the Go scripts in my $GOPATH. This is the HEAD script, which is printing the error message

"Usage: ", os.Args[0], "host:port"

This program is located in the $GOPATH

/Users/randomname/go/src/github.com/myname/head

I don't see why that would conflict with Ruby commands

/* Head
 */

package main

import (
	"fmt"
	"net/http"
	"os"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Println("Usage: ", os.Args[0], "host:port")
		os.Exit(1)
	}
	url := os.Args[1]

	response, err := http.Head(url)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(2)
	}

	fmt.Println(response.Status)
	for k, v := range response.Header {
		fmt.Println(k+":", v)
	}

	os.Exit(0)
}

this is my bash_profile. Question: Is there something in this file that's causing the conflict?

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

export PGHOST=localhost


export LASTFM_API='76479e879457be34dd1180f78e731fc0'

export PATH=${PATH}:/usr/local/mysql/bin
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"

export GOPATH=/Users/randomname/go/
export PATH=$GOPATH/bin:$PATH

# The next line updates PATH for the Google Cloud SDK.
source '/Users/my_name/google-cloud-sdk/path.bash.inc'

# The next line enables bash completion for gcloud.
source '/Users/randomname/google-cloud-sdk/completion.bash.inc'

alias goapp=~/google-cloud-sdk/platform/google_appengine/goapp

export PATH=/path/to/go_appengine:$PATH

答案1

得分: 0

我认为这个问题与你的问题有关。该问题已经在这里修复,但尚未发布。提交信息表明你可能没有安装GNU coreutils,所以你可以尝试使用以下命令安装:

brew install coreutils

但我不是OSX用户,所以不能确定这是否能解决问题。

英文:

I think this issue has to do something with yours. The issue is fixed here but have not been released yet. The commit message suggests that your may have not GNU coreutils installed, so perhaps you may want to install it using

brew install coreutils

But I'm not an OSX user so I can't be sure that this would fix it.

答案2

得分: 0

它正在尝试使用GNU head命令,并捕捉到你的版本,这是一个完全不同的程序,你需要将其名称更改为其他名称,并删除$GOPATH/bin/head

英文:

It's trying to use GNU head and it's catching your version, which is a completely different program, you will have to change the name to something else and delete $GOPATH/bin/head.

huangapple
  • 本文由 发表于 2014年7月12日 05:39:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/24706980.html
匿名

发表评论

匿名网友

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

确定