Search code examples
bashgitgnu-parallelgit-completion

git-completion.bash in .bashrc gives "env_parallel: Error: Your environment is too big."


When I load git-completion.bash in my ~/.bashrc, I get this error with env_parallel:

bash: /usr/bin/perl: Elenco degli argomenti troppo lungo
env_parallel: Error: Your environment is too big.
env_parallel: Error: You can try 3 different approaches:
env_parallel: Error: 1. Run 'env_parallel --session' before you set
env_parallel: Error:    variables or define functions.
env_parallel: Error: 2. Use --env and only mention the names to copy.
env_parallel: Error: 3. Try running this in a clean environment once:
env_parallel: Error:      env_parallel --record-env
env_parallel: Error:    And then use '--env _'
env_parallel: Error: For details see: man env_parallel

If I put env_parallel --session right before source ~/.git-completion.bash in my ~/.bashrc, I get this:

$ par echo hello ::: `seq 19` 
parallel: Error: Command line too long (124136 >= 64024) at input -18: 1

Solution

  • Log is as normally.

    Run this:

    env_parallel --record-env
    

    After this you can add . env_parallel.bash to your .bashrc.

    What happens is that GNU Parallel will determine which variables and functions are defined. It will ignore these. I.e. you probably do not care if the git-completion.bash functions are not copied to a remote server, because you only use those interactively.

    What you typically want is to have the functions and variables copied that you set after logging in. E.g.

    myfunc() { echo "This will be copied$myvar$@"; }
    myvar=", too"
    env_parallel --env _ -S server myfunc ::: '!'
    

    The list of names is stored in: ~/.parallel/ignored_vars. You should feel free to edit that list.

    See also: https://www.gnu.org/software/parallel/env_parallel.html