1

I tried to change the $PATH using the following command:

 export PATH=/opt/subversion/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin 

(i use the full variable because concatenating duplicated stuff or something)

However, on another terminal

echo $PATH

doesn't show the change (i've added the /opt/subversion/bin).

I read here: http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable that I should run

 . ./.profile 

But I get

 -bash: ‘export: command not found 

error on this command (I was on the home directory, after running 'cd').

Tried also to log off and on, no trace for the subversion I added to the path.

Have I missed something? Thanks.

2 Answers 2

0

Seems like something is wrong with the .profile file, there should be any sort of single quote before the export (See bash your error). I can't think of how that got there right now, but check the file for any strange character with cat -vE ~/.profile (Which hopefully works in OS X).

8
  • Thanks -- I ran $ cat -ve ~/.profile (with lowercase e, cause it threw an illegal option error), then got - ?M-^@M-^Xexport PATH=/usr/local/mysql/bin:M-^@M-^Y$ export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"$ Commented Oct 29, 2009 at 12:41
  • Having trouble parsing that .. :-), I don't what ^X is, are you editing this with some sort of unicode or funny gui editor? I might try recreating the file with some sort of emacs/vi editor. I think it might be hidden characters that are making this not work... Commented Oct 29, 2009 at 12:56
  • pastie.org/674928 - here are the commands. I've never edited this file before, only thru the terminal with 'export' command. I've just ran 'vi ~/.profile' and deleted the strange chars and saved. Now I've lost the vi command :| (the vim still opened). The . ./.profile now doesn't throw error. The echo $PATH shows: /usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/mysql/bin: Tried to edit the .profile again and adding the export command with the full variable and save, then ran . ./profile but $PATH still not full, and vi doesn't work. Thanks... Commented Oct 29, 2009 at 13:51
  • 1) No vi command (Probably because whereever it is, is no longer in your PATH). 2) 'Tried to edit the .profile again and adding the export command with the full variable and save,' Sorry, I am not quite sure what you mean with that, but whatever the original path is set to is porbably set in /etc/profile or /etc/bash.rc or something like that. So you can look at that file to see what orginally was. Commented Oct 29, 2009 at 15:10
  • YES!! I've opened .profile in a text editor and edited the path manually - pastie.org/675164 I've run the . ~/.profile and it worked! Thanks. Commented Oct 29, 2009 at 16:15
1

A few things:

  • Are you setting $PATH on the cmdline in terminal 1? If so, even with the export, terminal 2 won't see it. I assume this isn't the case because you mention .profile later, but it' wasn't completely clear to me.

  • After editing your ~/.profile (that's the .profile file in your home directory), doing

    . ~/.profile

Should source that file into the current environment.

  • Finally, I'm always nervous about setting path in a user file without building on the existing value of $PATH. You're forced to keep up with changes in the system-wide settings. So, I recommend you do something like:

    export PATH=$PATH:/path/to/perforce:/path/to/subversion:/path/to/git

You can put $PATH before or after your additions depending on what you want searched first.

If you've done as I've said with ~/.profile, please post the ~/.profile file for us and we'll go from there.

1
  • The value I've put in PATH was its exact value before the change so it's not "hard coding". As I mentioned - running . ~/.profile (or . ./.profile) threw an error (see Kyle's answer's comments). Thanks for the answer! Commented Oct 29, 2009 at 13:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.