From 7bb8dbabce83a3cd3c26fc5413a9a3429b97863b Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 21 Jul 2017 11:38:06 -0700 Subject: [PATCH] Reduce the strength of "arc executing on arc" from an error to a warning Summary: See PHI13. This was introduced a very, very long time ago in D311 and D312, and I think T168 was the original report. It prevents `arc` from being used in some semi-reasonable (maybe?) automation workflows where you're hooking some version of "Land Revision" up to `arc land`. This isn't necessarily the right approach, but I think the concession here to make this work is small. Running `arc` against another copy of `arc` makes `arc unit` not work, but we provide a good error message. Most other `arc` operations still work correctly. All of these situations are bizarre edge cases but I think we can safely warn and continue here. Even if we revert this behavior later, almost no one should be affected, since this essentially only impacts users developing `arc` itself. Test Plan: Ran one copy of `arc` against another, saw a warning instead of an error. `arc unit` failed, but with a good error. Reviewers: chad, jmeador Reviewed By: jmeador Differential Revision: https://secure.phabricator.com/D18264 --- scripts/arcanist.php | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index c0ae4d8c..b950dbbf 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -641,16 +641,33 @@ function arcanist_load_libraries( if ($ex->getLibrary() != 'arcanist') { throw $ex; } - $arc_dir = dirname(dirname(__FILE__)); - $error = pht( - "You are trying to run one copy of Arcanist on another copy of ". - "Arcanist. This operation is not supported. To execute Arcanist ". - "operations against this working copy, run `%s` (from the current ". - "working copy) not some other copy of '%s' (you ran one from '%s').", - './bin/arc', - 'arc', - $arc_dir); - throw new ArcanistUsageException($error); + + // NOTE: If you are running `arc` against itself, we ignore the library + // conflict created by loading the local `arc` library (in the current + // working directory) and continue without loading it. + + // This means we only execute code in the `arcanist/` directory which is + // associated with the binary you are running, whereas we would normally + // execute local code. + + // This can make `arc` development slightly confusing if your setup is + // especially bizarre, but it allows `arc` to be used in automation + // workflows more easily. For some context, see PHI13. + + $executing_directory = dirname(dirname(__FILE__)); + $working_directory = dirname($location); + + fwrite( + STDERR, + tsprintf( + "** %s ** %s\n", + pht('VERY META'), + pht( + 'You are running one copy of Arcanist (at path "%s") against '. + 'another copy of Arcanist (at path "%s"). Code in the current '. + 'working directory will not be loaded or executed.', + $executing_directory, + $working_directory))); } } }