Too many environment variables (Command failed: command too long)


I have an application that has grown fairly complex, and it has many external API integrations. Because of this, I have a lot of environment variables to hold various API keys and whatnot. However, I am now getting an error that pops up at the top of the screen (not in the terminal) saying “Command failed: command too long”. This happens once I have more than 16 environment variables.

I was not able to find any inherent limitations in Linux regarding the number of environment variables. Help? I can’t even get it to start running my application with this many variables, and it isn’t really an option to hard code them either because I’m not committing my keys to source control.



Thank you for writing in. Can you tell me a bit more about your runner configuration, or are you running the command within the terminal? Can you paste a screenshot showing the command and the output?




I’m using a runner configuration, yes. There’s no “command”, exactly, because I’m just clicking “Run”. Here’s what I get:

You can see that I’ve tried to fit more than the “allowed” 16 parameters by using the arrow keys to navigate in the ENV tab.


Any response from C9?


Hi @tsestrich,

Sorry for the late response.

The way that the ENV table works within runners is that it prepends the Environment variables to the actual command being executed, so something like:

ENV1=VAL ENV2=VAL .... command arg1 arg2

If you have a lot of variables, or a variable with a long length, the shell throws an error, as you saw. You can find out about the maximum length of the command line by running the following:

xargs --show-limits
Your environment variables take up 3007 bytes
POSIX upper limit on argument length (this system): 2092097
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2089090
Size of command buffer we are actually using: 131072

So, what can be done now? I would suggest creating a small shell script that set’s the environment variables, and then run it using the runner.

I hope this helps.



Okay, thank you! I’ll give that a try.


Okay, it took some time, but I figure this out. For anyone else wanting to run a shell script to set environment variables as part of a custom runner, you have to figure out a very specific and undocumented method of running the shell script. See my example below.

In short, you need prepend “nvm use default” with "source $project_path[location of your file]; " Notice the lack of a slash after $project_path.

// This file overrides the built-in Node.js (default) runner
// For more information see!/api/run-method-run
  "cmd": [
    "source $project_path.c9/runners/; nvm use default > /dev/null; node ${debug?--nocrankshaft --nolazy --nodead_code_elimination --debug-brk=15454} '$file' $args"
  "debugger": "v8",
  "debugport": 15454,
  "selector": "source.js",
  "info": "Your code is running at \\033[01;34m$url\\033[00m.\n\\033[01;31mImportant:\\033[00m use \\033[01;32mprocess.env.PORT\\033[00m as the port and \\033[01;32mprocess.env.IP\\033[00m as the host in your scripts!\n"

Your [] is then just a series of:

export VARNAME="value"

export VARNAME2="othervalue"