When writing to args.gn fails, should print contents |
|||||
Issue descriptionOn 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.
,
Sep 12 2016
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.
,
Feb 23 2017
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!
,
Nov 22 2017
I hit this again - I'm going to fix it.
,
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
,
Jan 12 2018
Technically it's not fixed until we roll gn, but I can wait. Marking as fixed. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by msrchandra@chromium.org
, Aug 5 2016