According to: tutorial/WolframSystemSessions
Initialization
On startup, the Wolfram Language kernel does the following:
Performs license management operations.
Runs Wolfram Language commands specified in any -run options passed to the kernel executable.
Runs the Wolfram Language commands in the systemwide initialization file
$BaseDirectory/Kernel/init.m.Runs the Wolfram Language commands in the user-specific initialization file
$UserBaseDirectory/Kernel/init.m.Loads
init.mandKernel/init.mfiles in Autoload directories.Begins running the main loop.
So I'd say that packages in Autoload have a freedom to do everything since everything should be already loaded. Yet this example fails:
dir = FileNameJoin[{$UserBaseDirectory, "Autoload", "Fetch", "Kernel"}];
CreateDirectory[dir, CreateIntermediateDirectories -> True]
SetDirectory @ dir;
Export[
"init.m",
"Print @ StringTake[URLFetch[\"www.wolfram.com\"], 300]; ",
"Text"]
Now quit the Kernel and evaluate something. I only get messages:
URLFetch::invhttp: Couldn't resolve proxy name.
StringTake[$Failed, 300]
Throw::nocatch: Uncaught Throw[False] returned to top level.
Throw::nocatch: Uncaught Throw[False] returned to top level.
Throw::nocatch: Uncaught Throw[False] returned to top level.
General::stop: Further output of Throw::nocatch will be suppressed during this calculation.
Break::nofwd: No enclosing For, While, or Do found for Break[].
While normally this procedure works StringTake[URLFetch["www.wolfram.com"], 300].
Question What's the problem? What more do we need to know about the Initialization stack? Are there any workarounds?
Currently I'm just setting procedure via ScheduledTask to fire 2 seconds later. But that's just silly.
This is not a question about URLFetch (yet good to know this specific problem) but about things I have to know to not be surprised next time.
Throw/Catchare implemented internally using this (C code level) abort machinery, they are not functional during initialization, so running any code using them is problematic. See also this. – ilian Mar 17 '16 at 15:03URLFetch::invhttp: Couldn't resolve proxy name.is caused somehow by the Catch/Throw issue you are talking about or is there something more? – Kuba Mar 31 '16 at 11:41sysinit.m– Szabolcs Nov 30 '16 at 14:59