# Arcanist
Arcanist is a CLI tool that helps you submit your code changes for code review. You can use it to
* create, submit and update diffs (`arc diff`);
* land the changes after they've been reviewed (`arc land` - this equivalent to a "Merge");
* run unit tests and check code coverage (`arc lint`, `arc unit`)
== Installing Arcanist and the linters ==
Make sure you have `php` installed in your system.
```lang=bash
mkdir -p ~/bin
cd ~/bin
git clone https://we.phorge.it/source/arcanist.git arcanist
git clone https://hub.sealcode.org/diffusion/124/arcanist-linters.git
git clone https://github.com/sealcode/arc-unit-mocha.git
ln -s arcanist/bin/arc arc
# Add ~/bin to your `PATH` variable, if it's not there already:
echo "export PATH=\$PATH:$HOME/bin" >> ~/.bashrc
echo "export PATH=\$PATH:$HOME/bin" >> ~/.zshrc
# restart the terminal and check if this command:
which arc
# returns: /home/<your_username>/bin/arc
# If it returns something else, like /usr/bin/arc, then uninstall the arcanist package provided by your package manager
```
## Configuration
Run:
```
# arc install-certificate https://hub.sealcode.org/
```
and follow the instruction. It's a one-time command that will save authorization info for the future.
## Changing the default editor
Arcanist uses your shell's default text editor for diff messages. To pick your default editor, set the `EDITOR` env variable to an editor of your choice (you can do this in `~/.bashrc`, `~/.bash_profile`, or similar)
## Using Arcanist
Arcanist is needed for smooth operation of the Review Workflow. Read more about how to use Arcanist in [this guide]https://hub.sealcode.org/w/sealhub_workflow/audyt-i-review/review-workflow/).
To quickly login and test if it's working properly, you can run:
```
arc install-certificate https://hub.sealcode.org
```
Then follow the instructions, and run
```
arc set-config phabricator.uri https://hub.sealcode.org
echo {} | arc call-conduit -- user.whoami
```
If you see a JSON output with your account data, arcanist is set up properly
## Multiple concurrent reviews on the same repo
You can work on multiple tasks in the same local repository. While you're waiting for your changes on task to be reviewed, create a new branch starting from `master`, make some commits, and use `arc diff` again to submit a new revision for review.
-----
## Troubleshooting
### Error: `"Arc was unable to automagically make a name for this patch"`
If after running `arc patch` for the same diff multiple times in the same repo you see a message like this:
```
name="arc patch"
Branch name arcpatch-D300 already exists; trying a new name.
Branch name arcpatch-D300_1 already exists; trying a new name.
Branch name arcpatch-D300_2 already exists; trying a new name.
Branch name arcpatch-D300_3 already exists; trying a new name.
Exception
Arc was unable to automagically make a name for this patch. Please clean up your working copy and try again.
(Run with `--trace` for a full exception trace.)
```
It means that `arc` ran out of branch names to keep your changes in.
```
name="git branch"
* alpha
arcpatch-D187
arcpatch-D188
arcpatch-D196
arcpatch-D213_1
arcpatch-D213_2
arcpatch-D217
arcpatch-D300_1
arcpatch-D300_2
arcpatch-D300_3
...
```
If you don't need those branches anymore, just delete them:
```
# git branch | cut -c3- | grep arcpatch- | xargs -n1 git branch -D
```
See https://secure.phabricator.com/T3277#33729 for more details
### Exception: Source file ".pinterest-linters/__phutil_library_init__.php" failed to load.
Solutions
1. Add `--recursive` flag to the `git clone` used for cloning pinterest linters repo, or
2. In arcanist linters repo, run `git submodule update --init`
### `failed to load symbol DomDocument` error
If you get this error, try installing the php-xml extension. On debian the command is:
```
sudo apt-get install php7.0-xml
```