Why am I getting KM Engine Logs about Local Variables?

@peternlewis, why am I getting KM engine log entries for Local Variables being "excluded from environment to ensure the environment is not too large"? Since Local Variables do NOT persist beyond execution of a macro, why would they be in the environment?

I'm keeping a close eye on my KME Log looking for suspicious entries.

Do I need to take any action to prevent these logs?

0097  2018-08-06 18:05:54 Variable “KMVAR_Local__LogLines” excluded from environment to ensure the environment is not too large
0096  2018-08-06 18:05:54 Variable “KMVAR_Local__LogLines” excluded from environment to ensure the environment is not too large
0095  2018-08-06 18:05:54 Variable “KMVAR_Local__FilteredResults” excluded from environment to ensure the environment is not too large
0094  2018-08-06 18:05:54 Variable “KMVAR_Local__LogLines” excluded from environment to ensure the environment is not too large

This happens when you run a script (AppleScript, Shell Script, etc).

As you know, the variables are placed into environment variables, with names that start with KMVAR.

However then total space for the environment variables is limited (by an unspecified limit, sigh), and if the total size of the environment variables exceeds this limit, then the script will not run at all (the attempt to start the script will fail). So Keyboard Maestro takes care to ensure that the total size of the environment variables it includes total up to less than around 100k. If the total size of all your variables (which includes non-password variables, local variables and instance variables) exceeds 100k, then the largest of them will be omitted.

The notification in the log is so if that happens to be a variable you really want to access, and it is not there, you have a change of figuring out what is going on.

You can always access larger variables via AppleScript to the Keyboard Maestro Engine as normal.

So no, you don't have to take any action to prevent these log entries and unless you need to use those specific variables in your scripts, you don't need to do anything.

I trust that is clear.

So what happens if the total of all variables, including Local variables, exceeds 100K while a macro is running?

I have a macro that is exporting data from the KM log (via shell script), filtering it with JXA, then opening the results in BBEdit. Should I be doing all of that with files instead of KM Variables?

Nothing. Keyboard Maestro itself can have arbitrarily large variables.

It is only environment variables that have a system limitation.

If a variable is larger than a 100k then it wont be passed to the script as an environment variable. If it is large, but smaller than 100k, then it might not be passed to the script as an environment variable. So when dealing with passing Keyboard Maestro variables to scripts, if they might be large, then you may have to have the script read them from the Keyboard Maestro Engine via AppleScript, rather than using the KMVAR environment variable copy of the variable.

OK, that helps. It shouldn't be a problem in my macro since I don't use KMVAR environment variables anywhere.

Hey JM,

You don't have any shell scripts that call Keyboard Maestro variables?

-Chris

No. I use two shell scripts:

  1. One exports the log and outputs to the JXA script
  2. One takes a KM Variable as input, and output to another KM Variable, both outside the script, part of the Execute Script action.

For example:
image