Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is really driving me crazy.

In one cell, I change $Path by removing from it un-needed paths that I do not want for the duration of a computation I will be doing.

Immediatly after, in new cell, I type $Path and see it was changed ok.

Now, I open a new cell, and do the same. I type $Path again, and now I see some of the $Paths I removed are back again! Here is a screen shot from my notebook now

enter image description here

You can see the variable $Path now has changed, on its own.

This is what I type

$Path =DeleteCases[$Path, "C:\\Users\\me"];
$Path =DeleteCases[$Path, "."];
$Path =DeleteCases[$Path,"C:\\Program Files\\Wolfram Research\\Mathematica\\8.0.4\\AddOns\\LegacyPackages"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Kernel"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Kernel"];
$Path=DeleteCases[$Path,"C:\\Program Files\\Wolfram

Then in new cell


Then in new cell the same. And now the $Path has been reset.

I noticed this when I was calling Leonid function he posted, and in it, it uses $Path, but I noticed I was getting packages that should not show up since I changed the $Path before calling it.

This is really strange. I am using V 8.0.4 on windows 7


Just installed version 9. Not able to reproduce this. Using the same PC, same notebook, same steps. So it looks like, whatever it was, is fixed in Version 9.

share|improve this question

closed as off-topic by Kuba, Öskå, Louis, m_goldberg, ilian Dec 5 '15 at 19:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Kuba, Öskå, Louis
If this question can be reworded to fit the rules in the help center, please edit the question.

Regardless of the origin of this, you can use Block[{$Path= DeleteCases[$Path,...]},...] around the function, to get rid of those directories dynamically. – Leonid Shifrin Nov 28 '12 at 18:41
Thanks, Nasser,but my comment does not really explain what you observed, so it won't make a good answer to your question. – Leonid Shifrin Nov 29 '12 at 8:10
I'm voting to close this question as off-topic because the problem the user is experiencing can not be reproduced by others. – m_goldberg Dec 5 '15 at 19:02