0
$\begingroup$

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`
{"/Applications/Mathematica11.app/Contents/AddOns/Applications", \
"/Applications/Mathematica11.app/Contents/SystemFiles/Links", \
"/Users/gkdgoutam/Library/Mathematica/Kernel", \
"/Users/gkdgoutam/Library/Mathematica/Autoload", \
"/Users/gkdgoutam/Library/Mathematica/Applications", \
"/Library/Mathematica/Kernel", "/Library/Mathematica/Autoload", \
"/Library/Mathematica/Applications", ".", "/Users/gkdgoutam", \
"/Applications/Mathematica11.app/Contents/AddOns/Packages", \
"/Applications/Mathematica11.app/Contents/SystemFiles/Autoload", \
"/Applications/Mathematica11.app/Contents/AddOns/Autoload", \ .   
"/Applications/Mathematica11.app/Contents/AddOns/Applications", \
"/Applications/Mathematica11.app/Contents/AddOns/ExtraPackages", \
"/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.

$\endgroup$

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.

  • $\begingroup$ Basically following this I messed up mathematica.stackexchange.com/questions/165418/… $\endgroup$ – Boogeyman May 14 '18 at 14:03
  • $\begingroup$ Did you modify your kernel init.m as described here? If <<MT` does something expected, check what file it loads using FindFile["MT`"]. $\endgroup$ – Szabolcs May 14 '18 at 14:10
  • $\begingroup$ Yes, unfortunately I did. FindFile["MT`"] gives /Users/gkdgoutam/Library/Mathematica/Kernel/MT.m $\endgroup$ – Boogeyman May 14 '18 at 14:12
  • $\begingroup$ Thanks. I deleted from there. But still in \$Path there are 3 such paths exist. How do I remove two of them? $\endgroup$ – Boogeyman May 14 '18 at 14:13
  • $\begingroup$ 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. $\endgroup$ – Boogeyman May 14 '18 at 14:21
0
$\begingroup$

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 }]];

Then add the Autoload/init.m in Kernel (if not done already) i.e. in

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

by adding the following:

Get[ToFileName["/Users/gkdgoutam/Library/Mathematica/Autoload","init.m"]]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.