auto icon indicating copy to clipboard operation
auto copied to clipboard

Determine cause of auto-exec spawnSync /bin/sh E2BIG

Open jdalrymple opened this issue 4 years ago • 11 comments

Describe the bug

Currently my latest build fails on the release step with a E2BIG error. I've done some research and found this can be due to a few reasons such as to many command argument (doesn't seem like the case here) or texts that are too large.

I feel like it may be the latter, but im unsure of how to debug the issue.

Ill try a temporary work around and comment my auto-exec lines, but any suggestions are welcome!

To Reproduce

Trying to figure that out right now.

Expected behavior

Either mention the troubling file, or not throw an error

Environment information:

Gitlab CI & Local (arch linux machine)

Additional context

I don't think this is necessarily due to auto. Most likely a spawn problem, just figured it would be helpful to post here for anyone who runs into a similar issue in the future, and to brain storm debugging ideas.

jdalrymple avatar Jun 12 '20 10:06 jdalrymple

I think that this may be a fatal flaw in the exec plugin.

E2BIG means that there were too many args to the execSync call. I'm pretty sure that the args it's talking about it just all the hook info we pass in though env variables ($ARG0).

I'm not really sure if this is something we can even fix. Might have to document this limitation and maybe even add an option to forgo passing in the contextual information.

hipstersmoothie avatar Jun 12 '20 17:06 hipstersmoothie

A solution could be storing the args somewhere on disk and let the command pull from there instead of an env var. But that's a pretty big breaking change for the plugin

To unblock you this plugin does the same thing

const { SEMVER, execPromise, getCurrentBranch } = require("@auto-it/core");

module.exports = class NextCherryPickPlugin {
  constructor() {
    this.name = "update docs";
  }

  /**
   * Setup the plugin
   *
   * @param {import('@auto-canary/core').default} auto
   */
  apply(auto) {
    auto.hooks.beforeCommitChangelog.tapPromise(this.name, async (config) => {
      await execPromise("yarn", ["lint:doc:fix"]);
      await execPromise("git", ["add", "."]);
    });
  }
};

hipstersmoothie avatar Jun 12 '20 17:06 hipstersmoothie

If you can find a solution to E2BIG that would be awesome! (or anyone else who sees this issue)

hipstersmoothie avatar Jun 12 '20 17:06 hipstersmoothie

I'll definitely think about it, there should be some way to work around it. Thanks!

jdalrymple avatar Jun 13 '20 17:06 jdalrymple

I see in the execSpawn args list we pass process.env fully on top of the auto context, maybe the option we add could specify to only pass auto-specific env vars?

sumwatshade avatar Jan 12 '21 00:01 sumwatshade

I (an interested bystander) wholeheartedly endorse the "storing args in a file" solution. Yes, it's a breaking change, but it's a breaking change you need.

@hipstersmoothie

To unblock you this plugin does the same thing

To be clear, to use this I just save it in my (non-Node/NPM/TypeScript) repo and set "plugins": ["path/to/file"] in my config file, or is there more to it?

jwodder avatar Jun 11 '21 15:06 jwodder

Any progress here? My case is where I have 1.8mb as an argument I'm passing into a CLI tool.

onassar avatar Sep 09 '21 05:09 onassar

another "ad-hoc" approach, which would be backward compatible with existing plugins etc but not work entirely correctly if encountering large changelog would be: if encountering value too large for a single env var - split into multiple env vars to be stitched together upon consumption. I.e. instead of a single ENVVAR, split into ENVVAR, ENVVAR_1, ENVVAR_2 and so on, with code in consuming plugin reconstructing from all ENVVAR{,_*} while there are any.

yarikoptic avatar Nov 02 '21 12:11 yarikoptic

Ping on this issue. Even having started to cut releases more often to minimize changelog size we keep running into this issue. It is frustrating and I wonder how auto manages to work for others more reliably .

yarikoptic avatar Aug 04 '22 10:08 yarikoptic

Ran into this issue when using auto-exec with beforeCommitChangelog: 'yarn run prettier --write .',.

ℹ  info      Supplied Environment (name and char size):
	...
	ARG_0=169526
✖  error     Received E2BIG from execSync.

My usage doesn't require the ARG_* env vars. A solution could be to provide a new configurable option to disable the ARG_* functionality for people who don't need it.

jameslnewell avatar Mar 07 '23 00:03 jameslnewell

@jameslnewell feel free to submit a PR for that

hipstersmoothie avatar Mar 10 '23 21:03 hipstersmoothie