# LocalSymbol remains unevaluated in autoload package?

I am using LocalSymbol to store some database credentials. I put a statement like this in a user-level autoload package:

$PostgresCredentials = LocalSymbol @ "DefaultPostgres";  This returns unevaluated when this package is autoloaded (i.e. it evaluates to LocalSymbol @ "DefaultPostgres"). Evaluate does not fix the issue. If I reload the package manually after my session has started, then $PostgresCredentials correctly pulls the LocalSymbol. And of course if I define it with SetDelayed it will work.

I am just wondering what the problem is. Is it possible to access a LocalSymbol at the autoload stage?

• I have not tried to reproduce this problem, but I know that there are several things that do not work during kernel initialization. The typical symptoms tend to be different from what you describe though. Take a look at this question and the links within: mathematica.stackexchange.com/q/132212/12 – Szabolcs Feb 20 '17 at 22:01
• My point is that there are many limitations during initialization, and you may be forced to roll your own persistent storage implementation. One way is to write/read an .m file to/from \$UserBaseDirectory/ApplicationData/YourPackageName. Use Put/Get to do this, not Export/Import. Export/Import does not work during initiailzation. A nice way is to just put an association with string keys into that .m file. – Szabolcs Feb 20 '17 at 22:03
• Another thing: I would be cautious with LocalSymbol if you plan to distribute your package. LocalSymbol has trouble with paths that contain spaces. Windows encourages usernames with spaces, which means that LocalSymbol's default storage location will often have spaces on Windows ... – Szabolcs Feb 20 '17 at 22:06
• @Szabolcs Thanks. I did intend to use it for packages so I will avoid this can of worms. I'll use your Get suggestion instead. – mfvonh Feb 21 '17 at 0:25