Search code examples
rubygorbenv

Ruby commands conflicting with program in $gopath


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

Solution

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