The list of arguments and the environment of a command are copied in the same space in memory when a program starts. The error message is “Argument list too long”, but in fact the exact error is that the argument list plus the environment is too long.
This happens as part of the
execve system call. Most if not all unix variants have a limit on the size of this temporary space. The reason for this limit is to avoid a buggy or malicious program causing the kernel to use a huge amount of memory outside of that program's own memory space.
The POSIX standard specifies that the maximum size of this memory space must be at least
ARG_MAX, and that the minimum value of that (
_POSIX_ARG_MAX) is 4096. In practice most Unix variants allow more than that, but not 10MB. You can check the value on your system with
getconf ARG_MAX. On modern Linux systems, the maximum is 2MB (with typical settings). Traditionally many systems had a 128kB limit. Linux also still has a 128kB limit for the value of a single argument or the definition of an environment variable.
If you need to pass more than a few hundred bytes of information, pass it in a file.