How to permanently modify the $Path in Mathematica [duplicate] This question already has an answer here: I was trying to add permanently a path inside$Path.

"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0"


Following $Path manual I did the following AppendTo[$Path, FileNameJoin[{$HomeDirectory, "/Softwares/HEP_Softwares/MT-1.0""}]];  which does it successfully. However when I quit kernel it goes away. Then following some other Q/A I have messed with something. Now whenever I do to load the package <<MT  it appends the path /Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0  in \$Path and does not load the package. Is there any way to overcome the situation without changing my previous definitions of \$Path ? Also what is the best way to add a path in$Path permanently? This question may be duplicate but a clear answer is still lacking.

Whenever I do

<<MT
"/Users/gkdgoutam/Library/Mathematica/Kernel", \
"/Users/gkdgoutam/Library/Mathematica/Applications", \
"/Library/Mathematica/Applications", ".", "/Users/gkdgoutam", \
"/Applications/Mathematica11.app/Contents/SystemFiles/Kernel/\
Packages", \
"/Applications/Mathematica11.app/Contents/Documentation/English/\
System",
"/Applications/Mathematica11.app/Contents/SystemFiles/Data/\
ICC",     "/Users/gkdgoutam/Softwares/HEP_Softwares/HPL", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/HypExp", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0", \
"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0"}


Update: Basically I want a clear view/answer on how to edit the output of \$Path so that I can in principle put any PATH which Mathematica will search by default every time I open Mathematica and which will show up in output of \$Path. Since I have somehow messed with I wanted to look at the file itself where I can add/remove the PATHs. For example in this case I want to remove multiple entry of

"/Users/gkdgoutam/Softwares/HEP_Softwares/MT-1.0"


from \$Path. marked as duplicate by Kuba♦May 16 '18 at 11:45 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. • Basically following this I messed up mathematica.stackexchange.com/questions/165418/… – Boogeyman May 14 '18 at 14:03 • Did you modify your kernel init.m as described here? If <<MT  does something expected, check what file it loads using FindFile["MT"]. – Szabolcs May 14 '18 at 14:10 • Yes, unfortunately I did. FindFile["MT"] gives /Users/gkdgoutam/Library/Mathematica/Kernel/MT.m – Boogeyman May 14 '18 at 14:12 • Thanks. I deleted from there. But still in \$Path there are 3 such paths exist. How do I remove two of them? – Boogeyman May 14 '18 at 14:13
• Okay. I found the place. ~/Library/Mathematica/Autoload where other paths are also appended, so there I have put the new path. Also from ~/Library/Mathematica/Autoload/init.m I have removed the extra paths. – Boogeyman May 14 '18 at 14:21

Okay for future reference this could be one answer:

Check the Autoload and Kernel path by $Path. One can then add the desired PATH (in this case /Users/gkdgoutam/Softwares/HEP_Softwares/MT ) inside /Users/gkdgoutam/Library/Mathematica/Autoload/init.m  For example: $MTPath = "/Users/gkdgoutam/Softwares/HEP_Softwares/MT"
If[Not[MemberQ[$Path,$MTPath]],$Path = Flatten[{$Path, \$MTPath }]];


/Users/gkdgoutam/Library/Mathematica/Kernel/init.m

Get[ToFileName["/Users/gkdgoutam/Library/Mathematica/Autoload","init.m"]]
`