# Tag Info

32

Short answer The local variables of the form varname$... are used by the system, and it is unwise to use symbols with such names as local variables. With, like many other lexical scoping constructs, performs excessive renamings, often even in cases where it isn't strictly necessary. This probably has to do with efficiency - full analysis may be more costly. ... 29 You should consider using the sandbox functionality. You can create a subkernel and put it in sandbox mode this way: link = LinkLaunch[First[$CommandLine]<> " -wstp -noicon"]; LinkWrite[link, Unevaluated@EvaluatePacket[DeveloperStartProtectedMode[]]]; You can then interact with this subkernel using the standard LinkWrite and LinkRead functions. If ...

29

There are two processes running. The first process is the FrontEnd. The FrontEnd receives your keypresses and renders text and plots. The second process is the Kernel. The Kernel receives commands to perform calculations, stores the states of variables, and does pretty much all the calculating. When you press Alt-., the FrontEnd immediately receives ...

25

As people have figured out in the comments, this was a quite deliberate decision on our part. One which I can take a significant amount of credit/responsibility/blame for. First a little bit about the extra kernel. The kernel is enabled using a password which causes it to run in Wolfram Player mode. It runs using the same binary as the regular kernel, ...

23

To access the errors, you need to invoke the Front End directly from the kernel. In effect, you end up telling the kernel to tell the FE to tell the kernel to do something, so that the FE can report any errors it finds. The method I use is ClearAll[getFrontEndErrors]; SetAttributes[getFrontEndErrors, HoldAllComplete]; getFrontEndErrors[expr_] := Block[{...

20

You could launch a different kernel and use that to run the computation. You will be controlling this "slave kernel" from another Mathematica session. This will allow you to script even quitting and restarting the slave kernel. Using parallel tools This is simpler and I recommend trying this approach first. Launch a single kernel: kernel = ...

19

You need to daemonize your script: nohup math -script test.txt 0<&- &>/dev/null & Now this will run as a background process with no output captured. If your script does indeed produce output, just replace /dev/null with the filename. In order to daemonize something you need to disconnect all the automatically connected streams (stdin, ...

17

This can be relatively easily done using extremely useful $FrontEnd option "ClearEvaluationQueueOnKernelQuit" introduced by Chris Degnen. Usage Print @$SessionID quitAndEvaluate[ Print @ $SessionID ] 25183094379509806957 25183094575602627552 quitAndEvaluate[] will restart kernel without aby additional tasks. It may be useful if you want to ... 16 I have been solving exactly the same problem about 2 years ago (http://community.wolfram.com/groups/-/m/t/125587?p_p_auth=aZGMz5bs). Students are uploading piece of Mathematica (Wolfram Language) code which is run by a testing script (in Mathematica) and the results are compared with a reference solution. To prevent the students to run potentially dangerous ... 16 One approach would be to run the evaluation in a second kernel which is controlled from a main kernel through MathLink/WSTP. Then your main kernel can detect if the MathLink connection dies. You can implement this manually (a lot of work), or you can try to do it using the parallel computing tools, where much of the groundwork is already laid down. In ... 16 The kernel crashes due to stack overflow. It is not safe to recurse too deeply. Increasing$RecursionLimit to values that are too great (and actually recursing that deep) risks a crash. (So yes, in a way it's due to insufficient memory, but it has nothing to do with memoization. It is due to insufficient stack space.) From the documentation: On most ...

15

In addition to assigning to In, the Mathematica main loop assigns the input to InString before it is parsed as an expression. You can then retrieve InString[1] and parse the result with ToExpression, wrapping it in Defer to prevent it from evaluating immediately: In[5]:= ToExpression[InString[1], StandardForm, Defer] Out[5]= Round[SessionTime[]] You can ...

15

You can use GNU screen to make a sort of persistent terminal that allows you to resume work wherever you left off. Take a look at the many tutorials available. It's not completely clear from your question whether the better solution is this, or nohup (see Stefan's answer). Use nohup if your workflow is non-interactive: log in, start a batch job that ...

15

There is a setting in Mathematica that controls whether it can access the internet. Go to Preferences -> Internet Connectivity and uncheck "Allow the Wolfram System to access the Internet". Disabling this will disable some features that depend on internet access, such as Wolfram|Alpha queries. This setting can also be controlled by the $AllowInternet ... 15 Apparently, Throw is deactivated during kernel initialization. The following function can determine if Throw is inoperative: throwInoperativeQ[] := CheckAll[Catch[Throw[False]], # /. Null -> True &] The undocumented function CheckAll is used here because Check also appears to be unreliable when Throw is inoperative. If we make the assumption that ... 14 After some spelunking, I found a file which contains a lot of initialization code, including reading the kernel init.m file, loading Autoload packages, loading anything set with the -initfile option, starting the paclet manager (which may autoload packages), and many other things. It is SystemFiles/Kernel/SystemResources/$SystemID/sysinit.m Towards the ...

14

This bug has been fixed by a paclet update. This would be applied automatically whenever the functionality is used in a new kernel (as long as the paclet manager has updated its local site index, which typically happens once per session). To force an immediate installation, evaluate PacletSiteUpdate /@ PacletSites[]; PacletInstall["FFmpegTools"] which ...

13

This message is issued by Function itself. To see this, try Function[Module[{slot = 1}, Slot[slot]]] If Function has named formal parameters, the message goes away: Function[x, Module[{slot = 1}, Slot[slot]]] So to fix this first we need to find out where is the argument passed to ParallelEvaluate wrapped by Function. Fortunately the parallel tools are ...

13

Updated This happens because your DynamicModule returns a dynamic object of which x is passed on to the front-end before the scheduled task starts, so the front-end-x cannot be modified anymore by any process (more details at the end). The problem can be further simplified. This works: RemoveScheduledTask@ScheduledTasks[]; DynamicModule[{x = 0}, ...

13

You cannot Quit kernel while evaluation is still running: the Quit[] command will be placed in the queue and executed only after finishing of evaluation of all the previous inputs. In contrast, Evaluation ► Quit Kernel will quit the kernel immediately even if it is still running. UPDATE As Kuba noticed in the comments, via "Preemptive" link it is ...

13

Assuming FrontEnd survives, prepare 3 cells: (*init cell, won't be needed later*) state = CurrentValue[EvaluationNotebook[], {"TaggingRules", "state"}] = 0; SetOptions[ #, {CellTags -> {"Procedure"}, ShowCellTags -> True} ]& /@ {NextCell[], NextCell @ NextCell[]}; CurrentValue[$FrontEndSession, "... 13 Update Leaving my original answer below for historical purposes, however it only applies up until version 11.1.1. As of version 11.2.0, the kernel startup initialization has been overhauled and this example (as well as others) now works correctly: placing the URLFetch call in init.m does result in an output like <!doctype html> <html lang="en" ... 13 It's a type of otherwise harmless bug that tends to come and go with versions. I would suggest to report it to Wolfram, but also not to worry about it. Notice that the symbols have no associated definitions, which means that they will not interfere with your code. A potential way in which such a situation can arise is the following. Imagine you put Sqr[x_] ... 12 Not a full answer, but a little too long for a comment. You may need to pay a close attention to licensing. If the results of your computation are used on a single machine (e.g. somehow saved to a database or used further in the computation), you may only need a professional single-machine license. If they are going to be used by other employees / machines ... 12 Try this out: Lets say you have a variable called kernelA in one notebook using Kernel A. Then: CurrentValue[$FrontEndSession, {TaggingRules, "KernelA"}] = kernelA In your other notebook, running Kernel B just evaluate variableFromOthernotebook = CurrentValue[\$FrontEndSession, {TaggingRules, "KernelA"}] Edit An alternative that might be faster (almost ...

12

Now that the workaround has worked for me for days without crash, let me put it as an answer myself. The crash (at least in my case) is because of the kernel tries to connect to internet and something wrong happened there. To solve the problem, uncheck Preference -> Internet Conectivity -> Allow the Wolfram System to access the Internet

12

Here's an approach to fix the code behind Terminal - Execute the following code to restore the functionality of the package: << Terminal ExportString["", "TTY"]; DownValues@SystemConvertBitmapDumpExportTTY = DownValues@SystemConvertBitmapDumpExportTTY /. { TextStyle -> LabelStyle, HoldPattern[pre : (data_ = _[___, gr_, "...

11