1

I have an environment variable $GOPATH set in ~/.profile:

export GOPATH=$HOME/gopkgs:$HOME/code/go

Now I want to use $GOPATH to add the ./bin sub-directory of the two folders to $PATH, preferably in ~/.profile as well.

I am trying:

export PATH=$PATH:$HOME/go/bin:${GOPATH//://bin:}/bin

This only prevents me from logging into an X session. The distro is Linux Mint 11 x64.

What am I missing?

Alvin Reyes
  • 2,889
  • 16
  • 38

1 Answers1

4

On my machine this works and

echo PATH=$PATH:$HOME/go/bin:${GOPATH//://bin:}/bin

substitutes to:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/home/l1zard/go/bin:/home/l1zard/gopkgs/bin:/home/l1zard/code/go/bin

Therefore i would guess that you have an error in your .profile.

however using the less complicated

export PATH="$PATH:$HOME/gopkgs/bin:$HOME/code/go/bin"

does not use fancy variable substitution but it should work. Also you do not need to log off and on again to make things work. you just need to source the .profile by typing:

source ~/.profile

This way you can also make sure that the .profile has no errors which might lead to not being able to log in to an X session.

l1zard
  • 315
  • 2
  • 7
  • Thanks! I'll just use the non-fancy method for now. Fancy substitution seems to work in a normal shell, but not in ~/.profile. – user1248304 Mar 05 '12 at 22:53