9
$\begingroup$

Bug introduced in 10.3.0 or earlier and fixed in 11.1

Bug reproduced on Win but not on Mac

Reply from WRI Support:

[...] This indeed seems to be an issue with the Frontend on Windows and I have alerted the development team about this.

Unfortunately I do not have a work around at this moment other than manually deleting it (and I understand that is not something you are interested in). [...]


Problem:

So, if your notebook has a private stylesheet and this stylesheet has a parent stylesheet, you can't delete the parent, in the same FE session, even after the notebook is closed.

Something like Default.nb (private) and Core.nb (its parent).

Implications

If your application have a more complex StyleSheets system and you want to incorporate some kind of automatic updating of the app, you will have a bad time replacing Package/FrontEnd/Stylesheets part.

Minimal example:

We are going to create a notebook, its private stylesheet and the stylesheet that this parent inherits from.

dir = FileNameJoin[{$HomeDirectory, "Desktop", "directory"}];
CreateDirectory@dir;
SetDirectory@dir;


nb = Notebook[{
    Cell[BoxData@RowBox@{"1", "+", "1"}, "Input"]},
   StyleDefinitions -> FileNameJoin[{dir, "privateStyles.nb"}]
   ];

privateStyles = Notebook[{
    Cell[StyleData[StyleDefinitions -> "defaultStyles.nb"]],
    Cell[StyleData["Input"], FontSize -> 25]
    }];

defaultStyles = Notebook[{
    Cell[StyleData[StyleDefinitions -> "Default.nb"]],
    Cell[StyleData["Input"], FontColor -> RGBColor[1, 0, 1]]
    }
   ];

Export["defaultStyles.nb", defaultStyles];
Export["privateStyles.nb", privateStyles];
Export["testNb.nb", nb]; (*this will give an error but it doesn't matter*)

NotebookOpen[
 FileNameJoin[{dir, "testNb.nb"}]
];

NotebookClose @ %;

DeleteFile /@ FileNames["*"]

DeleteFile::privv: Privilege violation for file or directory defaultStyles.nb. >>

{$Failed, Null, Null}

As you can see, the parent stylesheet can be easily deleted. Yet, its parent can't.

Question

Is there any way to proceed that doesn't involve closing the FrontEnd?

Edit by Mike H

This appears to be an OS or version specific problem:

enter image description here

$\endgroup$
  • 2
    $\begingroup$ Using 10.3.1 on OS X 10.10.5 all stylesheets were deleted $\endgroup$ – Mike Honeychurch Feb 29 '16 at 21:29
  • $\begingroup$ The problem appears in 10.1.0 under Windows 7. Which version are you running? $\endgroup$ – Mr.Wizard Mar 3 '16 at 10:22
  • $\begingroup$ @Mr.Wizard 10.3.1, have you tried in earlier releases? $\endgroup$ – Kuba Mar 3 '16 at 10:26
  • $\begingroup$ @Mr.Wizard considering the reply from WRI I've included, can we call it a bug? $\endgroup$ – Kuba May 13 '16 at 7:58
  • $\begingroup$ Smells like a bug to you, smells like a bug to me, and support doesn't think it should do that. Pretty easy decision. :^) $\endgroup$ – Mr.Wizard May 13 '16 at 9:23
2
$\begingroup$

In order to drop this topic from an unanswered stack:

Bug fixed in Mathematica V11.1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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