xargs: environment is too large for exec

2,624 views
Skip to first unread message

Martin Edwards

unread,
Nov 8, 2011, 2:28:57 PM11/8/11
to mintty-...@googlegroups.com
Hi, I'm not sure if this is a mintty or cygwin thing.

When I try and run keychain I get the following message
xargs: environment is too large for exec

Running set to see what environment variables are set and I see thousands of lines, it looks like lots of functions that have been set.

Is this something to do with mintty or cygwin, I thought I had a fairly plain cygwin setup with mintty on top.

Any pointers or help appreciated.

Chris Sutcliffe

unread,
Nov 8, 2011, 2:45:48 PM11/8/11
to mintty-...@googlegroups.com
On 8 November 2011 14:28, Martin Edwards wrote:
> When I try and run keychain I get the following message
> xargs: environment is too large for exec
>
> Running set to see what environment variables are set and I see thousands of
> lines, it looks like lots of functions that have been set.

Cygwin inherits Windows environment variables. Is you run 'set' from
a Windows Command Prompt, do you see thousands of lines? If so,
that's where they are coming from.

Cheers,

Chris

--
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

Kevin Calman

unread,
Nov 8, 2011, 4:34:59 PM11/8/11
to mintty-...@googlegroups.com
Execute the following, and please post the result: "set | wc -c"
--
Opinions herein are exclusively my own, unless you share them.
Kevin Calman, codex24 at gmail dot com, Austin, TX, US

Kevin Calman

unread,
Nov 8, 2011, 4:51:55 PM11/8/11
to mintty-...@googlegroups.com
On Tue, Nov 8, 2011 at 3:34 PM, Kevin Calman <cod...@gmail.com> wrote:
On Tue, Nov 8, 2011 at 1:28 PM, Martin Edwards <martinm...@gmail.com> wrote:
Hi, I'm not sure if this is a mintty or cygwin thing.

When I try and run keychain I get the following message
xargs: environment is too large for exec

Running set to see what environment variables are set and I see thousands of lines, it looks like lots of functions that have been set.

Is this something to do with mintty or cygwin, I thought I had a fairly plain cygwin setup with mintty on top.

Any pointers or help appreciated.



Execute the following, and please post the result: "set | wc -c"
As suggested in https://www.gnu.org/software/findutils/manual/html_node/find_html/Error-Messages-From-xargs.html, you could try " xargs --show-limits" and see what it inspires. Here's what I get:
$ set | wc -c
301369
$ xargs --show-limits
Your environment variables take up 2772 bytes
POSIX upper limit on argument length (this system): 27180
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 24408
Size of command buffer we are actually using: 27180

Execution of xargs will continue now, and it will try to read its input and run commands; if this is not what you wanted to happen, please type the end-of-file keystroke.
Warning: /bin/echo will be run at least once.  If you do not want that to happen, then press the interrupt keystroke.

$ keychain

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL

 * Found existing ssh-agent (2748)

$

Martin Edwards

unread,
Nov 9, 2011, 8:47:57 AM11/9/11
to mintty
Here's the output as requested.

$ set | wc -c
254252

$ set | wc -l
7368

$ xargs --show-limits
xargs: environment is too large for exec

So all the lines I see when I just run set, are they environment
variables and functions set by windows?

Martin

On Nov 8, 9:34 pm, Kevin Calman <code...@gmail.com> wrote:

Chris Sutcliffe

unread,
Nov 9, 2011, 9:39:24 AM11/9/11
to mintty-...@googlegroups.com
On 9 November 2011 08:47, Martin Edwards wrote:
> So all the lines I see when I just run set, are they environment
> variables and functions set by windows?

Quite possibly. As I mentioned in an earlier email, start a Windows
Command Prompt (cmd.exe) and type 'set', if you see thousands of
environment variables, then it is Windows that is setting these and
Cygwin is inheriting them.

Martin Edwards

unread,
Nov 9, 2011, 10:18:29 AM11/9/11
to mintty
I've run 'set' in a Windows command prompt and there are only about 40
lines as opposed to the 7368 lines when I run it in a cygwin/bash
prompt under Mintty.

Corinna Vinschen

unread,
Nov 9, 2011, 10:21:19 AM11/9/11
to mintty
On Nov 9 05:47, Martin Edwards wrote:
> Here's the output as requested.
>
> $ set | wc -c
> 254252
>
> $ set | wc -l
> 7368
>
> $ xargs --show-limits
> xargs: environment is too large for exec
>
> So all the lines I see when I just run set, are they environment
> variables and functions set by windows?

"set" in bash prints all variables and functions, not only the
environment. That's what the "env" command is for.

This looks like a bug in xargs. Even if the environment is too
big, it should print the information requested by --show-limits.

There's also another problem here. Under POSIX, the sysconf(_SC_ARG_MAX)
or ARG_MAX limit is the limit of environmant and arguments combined.
That's why xargs --show-limits subtracts the environment size from the
maxiumum usable command length:

$ xargs --show-limits
Your environment variables take up 1986 bytes
POSIX upper limit on argument length (this system): 27966
[...]
Maximum length of command we could actually use: 25980

Neither is the upper limit correct, nor does subtracting the environment
size make sense on Cygwin. These values are independent from each other.

As for ARG_MAX/_SC_ARG_MAX, it's set to 32000. That'a safe fallback for
calling native Windows applications.


Corinna

Kevin Calman

unread,
Nov 9, 2011, 12:21:29 PM11/9/11
to mintty-...@googlegroups.com
On Wed, Nov 9, 2011 at 9:21 AM, Corinna Vinschen <google...@vinschen.de> wrote:
This looks like a bug in xargs.  Even if the environment is too
big, it should print the information requested by --show-limits.
Even still, the results I got showed my environment is larger than Martin's and mine works, so there must be something else at work.

Martin, try this snippet:
$ env | awk -F= '{I=$1;sub(/_.*$/,"",I);C[I]++};END{for (J in C) if (C[J] > 1) printf "%d\t%s\n", C[J], J}' | sort -nk1
2       M2
2       SSH
2       windows
3       JAVA
5       PROCESSOR
5       TEXDOCVIEW
The command produces a table of counts of environment entry names truncated at the first '_' character. This will give you an idea of where large numbers of environment entries are coming from. For example, the last result above is due to my environment containing:
$ env | grep \^TEXDOCVIEW
TEXDOCVIEW_dvi='cygstart %s'
TEXDOCVIEW_html='cygstart %s'
TEXDOCVIEW_pdf='cygstart %s'
TEXDOCVIEW_ps='cygstart %s'
TEXDOCVIEW_txt='cygstart %s'
You could then remove these environment definitions (from the current session only) with something like,
for I in $(env | grep \^TEXDOCVIEW | cut -d= -f1); do unset $I; done

Try doing this to reduce your environment size until xargs works.

Andy Koppe

unread,
Nov 10, 2011, 4:40:51 AM11/10/11
to mintty
On Nov 9, 1:47 pm, Martin Edwards wrote:
> Here's the output as requested.
>
> $ set | wc -c
> 254252
>
> $ set | wc -l
> 7368
>
> $ xargs --show-limits
> xargs: environment is too large for exec
>
> So all the lines I see when I just run set, are they environment
> variables and functions set by windows?

I wouldn't be surprised at all if they were set by the ever-
troublesome bash-completion package. Try uninstalling that through
setup.exe or disabling it by renaming /etc/profile.d/
bash_completion.sh to something not ending in .sh. (Tab completion for
all the usual stuff such as commands and filenames will still work;
the bash-completion package adds completion for other command
arguments such as options or repository paths.)

In any case, the Cygwin mailing list would be a better place for this
thread.

Andy
Reply all
Reply to author
Forward
0 new messages