Closed Bug 1540270 Opened 5 years ago Closed 5 years ago

moz-phab runs `arc update`, which runs `git pull --rebase` in the wrong directory => e.g. "cannot pull with rebase: You have unstaged changes" or current working dir isn't part of a working copy of a vcs

Categories

(Conduit :: moz-phab, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: karlt, Assigned: glob)

Details

(Keywords: conduit-triaged)

Attachments

(1 file)

% DEBUG=1 moz-phab self-update
DEBUG    2019-03-30 09:46:27,635 $ /home/karl/.mozbuild/moz-phab/arcanist/bin/arc upgrade
Upgrading libphutil...
 Exception 
Command failed with error #128!
COMMAND
git pull --rebase

STDOUT
(empty)

STDERR
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

(Run with `--trace` for a full exception trace.)
WARNING  2019-03-30 09:46:27,718 arc failed to upgrade, which may be caused by using an arcanist package from
your system package manager.                                                                                            
Would you like to skip arc upgrades in the future? (YES/No)? 
DEBUG    2019-03-30 09:46:31,084 fetching https://api.github.com/repos/mozilla-conduit/review/releases/latest
[...]
DEBUG    2019-03-30 09:46:32,075 published_at: 2019-03-01 00:15:08
DEBUG    2019-03-30 09:46:32,075 m_time: 2019-03-26 21:00:09.090694
WARNING  2019-03-30 09:46:32,075 Update of `moz-phab` not required
% grep arc_last_check ~/.moz-phab-config
arc_last_check = 1550716502
% /home/karl/.mozbuild/moz-phab/arcanist/bin/arc --trace upgrade 
 ARGV  '/var/karl/moz/mozbuild/moz-phab/arcanist/bin/../scripts/arcanist.php' '--trace' 'upgrade'
 LOAD  Loaded "phutil" from "/var/karl/moz/mozbuild/moz-phab/libphutil/src".
 LOAD  Loaded "arcanist" from "/var/karl/moz/mozbuild/moz-phab/arcanist/src".
Config: Reading user configuration file "/home/karl/.arcrc"...
Config: Did not find system configuration at "/etc/arcconfig".
Working Copy: Reading .arcconfig from "/home/karl/moz/try/.arcconfig".
Working Copy: Path "/home/karl/moz/try" is part of `hg` working copy "/home/karl/moz/try".
Working Copy: Project root is at "/home/karl/moz/try".
Config: Did not find local configuration at "/home/karl/moz/try/.hg/arc/config".
Upgrading libphutil...
Working Copy: Reading .arcconfig from "/var/karl/moz/mozbuild/moz-phab/libphutil/.arcconfig".
Working Copy: Path "/var/karl/moz/mozbuild/moz-phab/libphutil" is part of `git` working copy "/var/karl/moz/mozbuild/moz-phab/libphutil".
Working Copy: Project root is at "/var/karl/moz/mozbuild/moz-phab/libphutil".
Config: Did not find local configuration at "/var/karl/moz/mozbuild/moz-phab/libphutil/.git/arc/config".
>>> [0] (+0) <exec> $ git rev-parse --git-dir
<<< [0] (+2) <exec> 2,712 us
>>> [1] (+2) <exec> $ git --version
<<< [1] (+4) <exec> 2,000 us
>>> [2] (+4) <exec> $ git status --porcelain=2 -z
<<< [2] (+10) <exec> 5,485 us
>>> [3] (+10) <exec> $ git symbolic-ref --quiet HEAD
<<< [3] (+12) <exec> 1,991 us
>>> [4] (+12) <exec> $ git pull --rebase
<<< [4] (+15) <exec> 2,475 us
>>> [5] (+15) <exec> $ git rebase --abort
<<< [5] (+39) <exec> 23,644 us

[2019-03-29 20:46:55] EXCEPTION: (CommandException) Command failed with error #128!
COMMAND
git pull --rebase

STDOUT
(empty)

STDERR
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
 at [<phutil>/src/future/exec/ExecFuture.php:380]
arcanist(head=stable, ref.stable=40a5dddbdd33), phutil(head=master, ref.master=524fcf465108)
  #0 ExecFuture::resolvex() called at [<phutil>/src/future/exec/execx.php:17]
  #1 execx(string) called at [<arcanist>/src/workflow/ArcanistUpgradeWorkflow.php:96]
  #2 ArcanistUpgradeWorkflow::run() called at [<arcanist>/scripts/arcanist.php:394]
% cd /var/karl/moz/mozbuild/moz-phab/libphutil
% git pull --rebase
Already up to date.
Current branch master is up to date.

This is repeatable despite choosing the default YES for the skip arc upgrades question.

It seems you're running a not released yet version of moz-phab.

Please run git status on the /home/karl/.mozbuild/moz-phab/arcanist/ directory.
You can delete the /home/karl/.mozbuild/moz-phab/ directory and clean Arcanist will be pulled on the next time you call moz-phab.
I will keep it open until we will be sure nothing weird is happening with the Arcanist's repository.

Flags: needinfo?(karlt)

Thank you for looking at this.

% cd /home/karl/.mozbuild/moz-phab/arcanist/
/var/karl/moz/mozbuild/moz-phab/arcanist
% git status
On branch stable
Your branch is up to date with 'origin/stable'.

nothing to commit, working tree clean
% cd
% rm -rf /home/karl/.mozbuild/moz-phab/
% moz-phab self-update
Installing arc
Cloning into '/home/karl/.mozbuild/moz-phab/arcanist'...
remote: Enumerating objects: 1129, done.
remote: Counting objects: 100% (1129/1129), done.
remote: Compressing objects: 100% (864/864), done.
remote: Total 1129 (delta 191), reused 854 (delta 157), pack-reused 0
Receiving objects: 100% (1129/1129), 757.76 KiB | 711.00 KiB/s, done.
Resolving deltas: 100% (191/191), done.
Cloning into '/home/karl/.mozbuild/moz-phab/libphutil'...
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (1015/1015), done.
remote: Compressing objects: 100% (876/876), done.
remote: Total 1015 (delta 109), reused 519 (delta 69), pack-reused 0
Receiving objects: 100% (1015/1015), 1.75 MiB | 489.00 KiB/s, done.
Resolving deltas: 100% (109/109), done.
Upgrading libphutil...
 Exception 
Command failed with error #128!
COMMAND
git pull --rebase

STDOUT
(empty)

STDERR
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

(Run with `--trace` for a full exception trace.)
arc failed to upgrade, which may be caused by using an arcanist package from
your system package manager.
Would you like to skip arc upgrades in the future? (YES/No)? 
Update of `moz-phab` not required

I'd somehow missed that the instructions indicate downloading a single file instead of pulling from github, so I also tried saving https://raw.githubusercontent.com/mozilla-conduit/review/a35696157c060cbc7a5a600f4d033f07b6c18da9/moz-phab to ~/bin/moz-phab

% chmod +x ~/bin/moz-phab
% rm -rf /home/karl/.mozbuild/moz-phab/
% ~/bin/moz-phab self-update           
Upgrading libphutil...
 Exception 
Command failed with error #128!
COMMAND
git pull --rebase

STDOUT
(empty)

STDERR
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

(Run with `--trace` for a full exception trace.)
arc failed to upgrade, which may be caused by using an arcanist package from
your system package manager.
Would you like to skip arc upgrades in the future? (YES/No)? 
Update of `moz-phab` not required
Flags: needinfo?(karlt)

looks like ~/.mozbuild/moz-phab/libphutil is the repo that's causing the problems, not ~/.mozbuild/moz-phab/arcanist.

kart - can you please do a git status on libphutil?

Flags: needinfo?(karlt)

Sure.

~% moz-phab self-update
Installing arc
Cloning into '/home/karl/.mozbuild/moz-phab/arcanist'...
remote: Enumerating objects: 1129, done.
remote: Counting objects: 100% (1129/1129), done.
remote: Compressing objects: 100% (864/864), done.
remote: Total 1129 (delta 191), reused 854 (delta 157), pack-reused 0
Receiving objects: 100% (1129/1129), 757.76 KiB | 209.00 KiB/s, done.
Resolving deltas: 100% (191/191), done.
Cloning into '/home/karl/.mozbuild/moz-phab/libphutil'...
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (1015/1015), done.
remote: Compressing objects: 100% (876/876), done.
remote: Total 1015 (delta 109), reused 519 (delta 69), pack-reused 0
Receiving objects: 100% (1015/1015), 1.75 MiB | 460.00 KiB/s, done.
Resolving deltas: 100% (109/109), done.
Upgrading libphutil...
 Exception 
Command failed with error #128!
COMMAND
git pull --rebase

STDOUT
(empty)

STDERR
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

(Run with `--trace` for a full exception trace.)
arc failed to upgrade, which may be caused by using an arcanist package from
your system package manager.
Would you like to skip arc upgrades in the future? (YES/No)? 
Update of `moz-phab` not required
~% cd /home/karl/.mozbuild/moz-phab/libphutil
/var/karl/moz/mozbuild/moz-phab/libphutil
~/.mozbuild/moz-phab/libphutil% git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Flags: needinfo?(karlt)

More evidence for the suspicion from https://mozilla.logbot.info/phabricator/20190404 :

git status --porcelain=2 -z and git symbolic-ref --quiet HEAD are run in the expected directory, but git pull --rebase ends up in the home directory:

% strace -e trace=execve,getcwd -f /var/karl/moz/mozbuild/moz-phab/arcanist/bin/../scripts/arcanist.php upgrade --trace
[...]
>>> [2] (+22) <exec> $ git status --porcelain=2 -z
strace: Process 25271 attached
[pid 25271] execve("/bin/sh", ["sh", "-c", "git status --porcelain=2 -z"], 0x565145192760 /* 75 vars */) = 0
[pid 25271] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 4096) = 42
[pid 25271] execve("/usr/bin/git", ["git", "status", "--porcelain=2", "-z"], 0x56454cb3f540 /* 75 vars */) = 0
[pid 25271] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25271] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25271] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25271] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25271] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25271, si_uid=1000, si_status=0, si_utime=0, si_stime=2} ---
<<< [2] (+74) <exec> 52,192 us
>>> [3] (+75) <exec> $ git symbolic-ref --quiet HEAD
strace: Process 25272 attached
[pid 25272] execve("/bin/sh", ["sh", "-c", "git symbolic-ref --quiet HEAD"], 0x565145192760 /* 75 vars */) = 0
[pid 25272] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 4096) = 42
[pid 25272] execve("/usr/bin/git", ["git", "symbolic-ref", "--quiet", "HEAD"], 0x5643ddad5540 /* 75 vars */) = 0
[pid 25272] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25272] getcwd("/var/karl/moz/mozbuild/moz-phab/libphutil", 129) = 42
[pid 25272] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25272, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
<<< [3] (+88) <exec> 13,051 us
>>> [4] (+88) <exec> $ git pull --rebase
strace: Process 25273 attached
[pid 25273] execve("/bin/sh", ["sh", "-c", "git pull --rebase"], 0x565145192760 /* 75 vars */) = 0
[pid 25273] execve("/usr/bin/git", ["git", "pull", "--rebase"], 0x56126c282510 /* 75 vars */) = 0
[pid 25273] getcwd("/home/karl/moz/try", 129) = 19
[pid 25273] getcwd("/home/karl", 129)   = 11
[pid 25273] getcwd("/home/karl", 129)   = 11
[pid 25273] getcwd("/home/karl", 129)   = 11
[pid 25273] +++ exited with 128 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25273, si_uid=1000, si_status=128, si_utime=0, si_stime=0} ---
[...]

The answer to "Would you like to skip arc upgrades in the future?" is now respected, thanks.

The processes that end up in the expected dirs chdir to /var/karl/moz/mozbuild/moz-phab/libphutil/ before exec'ing git.
The process for git pull --rebase does not. git changes to the home dir, presumably because the cwd /home/karl/moz/try has no git repo.

>>> [2] (+23) <exec> $ git status --porcelain=2 -z
strace: Process 26318 attached
[pid 26318] chdir("/var/karl/moz/mozbuild/moz-phab/libphutil/") = 0
[pid 26318] execve("/bin/sh", ["sh", "-c", "git status --porcelain=2 -z"], 0x55ec42c26760 /* 75 vars */) = 0
[pid 26318] execve("/usr/bin/git", ["git", "status", "--porcelain=2", "-z"], 0x55f720172540 /* 75 vars */) = 0
[pid 26318] chdir("/var/karl/moz/mozbuild/moz-phab/libphutil") = 0
[pid 26318] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=26318, si_uid=1000, si_status=0, si_utime=0, si_stime=2} ---
<<< [2] (+75) <exec> 51,665 us
>>> [3] (+75) <exec> $ git symbolic-ref --quiet HEAD
strace: Process 26319 attached
[pid 26319] chdir("/var/karl/moz/mozbuild/moz-phab/libphutil/") = 0
[pid 26319] execve("/bin/sh", ["sh", "-c", "git symbolic-ref --quiet HEAD"], 0x55ec42c26760 /* 75 vars */) = 0
[pid 26319] execve("/usr/bin/git", ["git", "symbolic-ref", "--quiet", "HEAD"], 0x55eafbeb5540 /* 75 vars */) = 0
[pid 26319] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=26319, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
<<< [3] (+83) <exec> 8,109 us
>>> [4] (+83) <exec> $ git pull --rebase
strace: Process 26320 attached
[pid 26320] execve("/bin/sh", ["sh", "-c", "git pull --rebase"], 0x55ec42c26760 /* 75 vars */) = 0
[pid 26320] execve("/usr/bin/git", ["git", "pull", "--rebase"], 0x55776fb41510 /* 75 vars */) = 0
[pid 26320] chdir("/home/karl")         = 0
[pid 26320] chdir("/home/karl")         = 0
Summary: "cannot pull with rebase: You have unstaged changes", even with Arcanist from moz-phab → moz-phab runs `arc update`, which runs `git pull --rebase` in the wrong directory => e.g. "cannot pull with rebase: You have unstaged changes" or current working dir isn't part of a working copy of a vcs

thanks for the detailed investigation karl!

here's the arc code in question: https://github.com/phacility/arcanist/blob/7329bc7c32b995a7dce0319723857cbdf4f95a91/src/workflow/ArcanistUpgradeWorkflow.php

given all arc does is some sanity checks followed by git pull --rebase we should run git directly instead arc upgrade. as our version of arc is private to moz-phab we can afford to skip the bulk of the checks.

Keywords: conduit-triaged
Priority: -- → P2

arc upgrade doesn't work in all scenarios; as all it does is some
sanity checks followed by git pull it would be quicker and easier to
diagnose issues if we switch to updating the libphutil and arcanist
repositories directly.

Assignee: nobody → glob
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: