Closed Bug 1472502 Opened 6 years ago Closed 6 years ago

`mach static-analysis clear-cache` fails with error "File exists: '~/.mozbuild/clang-tools'"

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: cpeterson, Assigned: andi)

Details

Attachments

(1 file)

`mach static-analysis clear-cache` fails if the directory ~/.mozbuild/clang-tools exists




# First remove clang-tools

~/Code/mozilla/firefox$ rm -rf ~/.mozbuild/clang-tools/

# `mach static-analysis clear-cache` succeeds and creates an empty directory called ~/.mozbuild/clang-tools

~/Code/mozilla/firefox$ mach static-analysis clear-cache
 0:00.93 Deleting cached artifacts and caches.

# `mach static-analysis clear-cache` fails because the directory ~/.mozbuild/clang-tools already exists

~/Code/mozilla/firefox$ mach static-analysis clear-cache
Error running mach:

    ['static-analysis', 'clear-cache']

The error occurred in the implementation of the invoked mach command.

This should never occur and is likely a bug in the implementation of that
command. Consider filing a bug for this issue.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

OSError: [Errno 17] File exists: '/Users/chris/.mozbuild/clang-tools'

  File "/Users/chris/Code/mozilla/firefox/python/mozbuild/mozbuild/mach_commands.py", line 1838, in clear_cache
    verbose=verbose)
  File "/Users/chris/Code/mozilla/firefox/python/mozbuild/mozbuild/mach_commands.py", line 2091, in _get_clang_tools
    os.mkdir(clang_tools_path)


clear_cache() calls _get_clang_tools(_get_clang_tools(force=True, download_if_needed=False):

https://searchfox.org/mozilla-central/rev/e45edf9ebc1f8e89686cace12c60085af7a4cdc5/python/mozbuild/mozbuild/mach_commands.py#1835,1837-1838

and then _get_clang_tools() finds ~/.mozbuild/clang-tools but doesn't delete it because download_if_needed is False. When _get_clang_tools() then tries to mkdir(), it fails:

https://searchfox.org/mozilla-central/rev/e45edf9ebc1f8e89686cace12c60085af7a4cdc5/python/mozbuild/mozbuild/mach_commands.py#2090-2091
The problem is not that I called `mach static-analysis clear-cache` twice. It's just that ~/.mozbuild/clang-tools exists. I hit the same mkdir() error with

$ mach static-analysis install
$ mach static-analysis clear-cache
Summary: `mach statis-analysis clear-cache` fails with error "File exists: '~/.mozbuild/clang-tools'" → `mach static-analysis clear-cache` fails with error "File exists: '~/.mozbuild/clang-tools'"
Andi, could you please take care of that? Thanks
Assignee: nobody → bpostelnicu
Thanks for reporting the bug. The main difference between install and clear-cache is that the later one deletes local artifacts and reset local artifact cache.
Comment on attachment 8989218 [details]
Bug 1472502 - fix mach static-analysis clear-cache.

https://reviewboard.mozilla.org/r/254258/#review261118

I wish we had tests for all this :)
Comment on attachment 8989218 [details]
Bug 1472502 - fix mach static-analysis clear-cache.

https://reviewboard.mozilla.org/r/254260/#review261120
Attachment #8989218 - Flags: review?(sledru) → review+
Yes, me two, but on automation, like taskcluster, we are not allowed to mingle with the artifacts downloaded. Everything must be done from the task yaml config file.
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/34fe97a415e3
fix mach static-analysis clear-cache. r=sylvestre
https://hg.mozilla.org/mozilla-central/rev/34fe97a415e3
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: