New issue
Advanced search Search tips

Issue 627656 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

When writing to args.gn fails, should print contents

Project Member Reported by brucedaw...@chromium.org, Jul 12 2016

Issue description

On a few occasions I have had gn clean fail with: "Error Failed to write args.gn". This is a data-loss scenario - I always expect gn to retain its arguments. Okay, not a *huge* data loss, but still, annoying.

I don't know what the cause is, but I do have a solution. The code (in tools\gn\command_clean.cc) could print the saved contents of args.gn to stdout, thus avoiding the data loss.

 
Components: Build
Labels: -Pri-3 OS-All Pri-2
Here's an example of this issue, and a related "gn clean issue"

First, I interrupted a build when the ninja files were being regenerated:

    D:\src\chromium\src>ninja -C out\Debug_component chrome
    ninja: Entering directory `out\Debug_component'
    [1 processes, 0/1 @ ?/s : 0.000s ] Regenerating ninja files
    ninja: error: rebuilding 'build.ninja': interrupted by user

Then I tried to do a gn clean:

    D:\src\chromium\src>gn clean out\Debug_component
    ERROR Not a build directory.
    This command requires an existing build directory. I interpreted your input
    "out\Debug_component" as:
      D:/src/chromium/src/out/Debug_component/
    which doesn't seem to contain a previously-generated build.

So that's one bug - gn clean does not correctly identify build directories. We can verify that this is an actual gn build directory with "gn gen":

    D:\src\chromium\src>gn gen out\Debug_component
    Done. Made 5293 targets from 1065 files in 1670ms

Whoops! gn clean now fails in a different way, and this time it destroys args.gn:

    D:\src\chromium\src>gn clean out\Debug_component
    ERROR Failed to write args.gn.
    D:\src\chromium\src>type out\Debug_component\args.gn
    The system cannot find the path specified.

If gn clean had printed the contents of args.gn (which it was holding in memory) when it failed then recovery would have been easier.

Status: Available (was: Untriaged)
I just got burned by this:

C:\Chromium\src>gn args out\Debug
Waiting for editor on "C:\Chromium\src\out\Debug\args.gn"...
Generating files...
Done. Made 4877 targets from 1195 files in 7958ms

C:\Chromium\src>gn clean out\Debug
ERROR Failed to write args.gn.

And out\Debug was gone!
Owner: brucedaw...@chromium.org
Status: Assigned (was: Available)
I hit this again - I'm going to fix it.
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 12 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b7c2c4ec1b901041af24793d679e3acaec4b750d

commit b7c2c4ec1b901041af24793d679e3acaec4b750d
Author: Bruce Dawson <brucedawson@chromium.org>
Date: Fri Jan 12 01:42:08 2018

Print args.gn if gn clean fails to write it

For mysterious reasons "gn clean" sometimes fails to write args.gn,
which is a surprisingly frustrating bit of data loss. This change gets
gn to do the most that it can in this case - print args.gn to the
console.

I tested by forcing a failure to write args.gn and verified that the
printout looked good and was usable.

Bug:  627656 
Change-Id: Ifbd6ddd8c851da13e482e8a0f617b218e29ede08
Reviewed-on: https://chromium-review.googlesource.com/862697
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528842}
[modify] https://crrev.com/b7c2c4ec1b901041af24793d679e3acaec4b750d/tools/gn/command_clean.cc

Status: Fixed (was: Assigned)
Technically it's not fixed until we roll gn, but I can wait. Marking as fixed.

Sign in to add a comment