13

Linux seems to have a default limit of 128KiB (131072) on the length of any single environment variable -- any attempt to set an envvar longer than this and then run any program will result in an 'Argument list too long' error.

This seems like it should be a configuration parameter, but I've been unable to find any way to raise it. Is there any way to increase it?

It is problematic for tools like "automake" which try to pull together long lists of files or tests in an environment variable as part of their building and testing process.

4
  • Take a look here: ARG_MAX, maximum length of arguments for a new process Commented Jan 12, 2017 at 17:52
  • @NarūnasK: Not terribly helpful as that only talks about the limit on the total of all arguments and envvars, not the limit on each envvar. Commented Jan 12, 2017 at 17:56
  • Did you check section: Number of arguments and maximum length of one argument? There's a hint about MAX_ARG_STRLEN (131072) Commented Jan 12, 2017 at 18:20
  • 2
    Also take a look here. It discusses your exact same problem. Commented Jan 12, 2017 at 18:25

1 Answer 1

15

MAX_ARG_STRLEN is a constant defined as PAGESIZE*32 in include/uapi/linux/binfmts.h. Its value cannot be changed without recompiling the kernel.

/* * These are the maximum length and maximum number of strings passed to the * execve() system call. MAX_ARG_STRLEN is essentially random but serves to * prevent the kernel from being unduly impacted by misaddressed pointers. * MAX_ARG_STRINGS is chosen to fit in a signed 32-bit integer. */ #define MAX_ARG_STRLEN (PAGE_SIZE * 32) #define MAX_ARG_STRINGS 0x7FFFFFFF 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.