0

I want to add texlive's directory to my PATH, so i type export PATH=$PATH:/usr/local/texlive/2018/bin/x86_64-linux and it update the PATH variable correctly. I can use commands listed in texlive path, and echo $PATH return the usual usr/bin AND texlive's path.

But when I close my terminal and open it again, it doesn't work anymore, and echo $PATH return /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin (Which is also kinda weird...).

Tried to edit .profile or .bashrc (I put export PATH=$PATH:/usr/local/texlive/2018/bin/x86_64-linux at the end), but bash doesn't seems to read it on new terminals.

TBrsx
  • 1
  • 2
    Please try to be more specific than "it's not working" - what did you try, exactly - and what happened? – steeldriver Feb 10 '19 at 18:08
  • 1
    ^ what steeldriver said, but you might find a solution here: How to add a directory to the PATH? – wjandrea Feb 10 '19 at 18:20
  • Edited to explain a little bit more. @wjandrea : I tried solutions listed here, but it doesn't change anything, PATH keeps reseting itself – TBrsx Feb 10 '19 at 19:33
  • It was the "not working" after editing the .profile that was of interest. What did you change in the .profile? That is the usual place to make such changes. – ubfan1 Feb 10 '19 at 19:53
  • 1
    Please note that if you change PATH by editing ~/.profile, you need to relogin before it takes effect. – Gunnar Hjalmarsson Feb 10 '19 at 20:10
  • @ubfan1 I didn't alter anything in .profile, I just added export PATH=$PATH:/usr/local/texlive/2018/bin/x86_64-linux at the end of it. The command works afterwards if I save and source it, but PATH still resets itself when I close the terminal.

    @GunnarHjalmarsson if I understood well, don't have to relogin if I do source ~/.profile. Just to be sure, I tried to reboot : still the same problem.

    – TBrsx Feb 10 '19 at 20:11
  • If you source a file, the commands in that file will only affect the current bash instance. So yes, you need to relogin if you want a persistent change of PATH. (Can't tell why a reboot wasn't sufficient for you.) – Gunnar Hjalmarsson Feb 10 '19 at 20:47

2 Answers2

1

I had the exact same issue. This worked.

Note: This would work only if you're using the bash shell. Run echo $SHELL on your terminal. If your terminal returns \bin\bash, then you're using bash.

  1. Remove export PATH="$PATH:YourPath" from .profile
  2. Run source .profile on the terminal in the home directory [This updates the path variables]
  3. Create .bashrc if it doesn't exit by running nano .bashrc
  4. Enter export PATH="$PATH:YourPath" into the file .bashrc
  5. Run source .bashrc

Your problem should be solved

0

Add export PATH="$PATH:<YourPath>" at the end of ~/.profile and don't forget to delete .bash_profile if you have it, because bash doesn't look at .profile if .bash_profile exists (per Why ~/.bash_profile is not getting sourced when opening a terminal?).

wjandrea
  • 14,236
  • 4
  • 48
  • 98
TBrsx
  • 1