Skip to content

Commit

Permalink
Fix eden du --clean on MacOS
Browse files Browse the repository at this point in the history
Summary:
`eden du --clean` currently fails with

```
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
```
Full error: P149352812

It looks like this is because Buck expects to run with a different python, so
here I clear out the PYTHONHOME variable before we start buck.

This reuses out logic used elsewhere to clean up the environment before
calling buck.

Reviewed By: wez

Differential Revision: D24904105

fbshipit-source-id: 73587c52aff3ea00f68339eb44e7042329de2e44
  • Loading branch information
kmancini authored and facebook-github-bot committed Nov 21, 2020
1 parent 8cb2b9b commit a46707c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 11 additions & 5 deletions eden/fs/cli/buck.py
Expand Up @@ -41,9 +41,9 @@ def is_buckd_running_for_path(path: str) -> bool:
return proc_utils.new().is_process_alive(buckd_pid)


def stop_buckd_for_path(path: str) -> None:
print(f"Stopping buck in {path}...")

# Buck is sensitive to many environment variables, so we need to set them up
# properly before calling into buck
def run_buck_command(buck_command: List[str], path: str) -> subprocess.CompletedProcess:
# Using BUCKVERSION=last here to avoid triggering a download of a new
# version of buck just to kill off buck. This is specific to Facebook's
# deployment of buck, and has no impact on the behavior of the opensource
Expand All @@ -69,8 +69,8 @@ def stop_buckd_for_path(path: str) -> None:
elif k.startswith("FB_PAR") or k.startswith("PYTHON"):
del env[k]

subprocess.run(
["buck", "kill"],
return subprocess.run(
buck_command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=path,
Expand All @@ -79,6 +79,12 @@ def stop_buckd_for_path(path: str) -> None:
)


def stop_buckd_for_path(path: str) -> None:
print(f"Stopping buck in {path}...")

run_buck_command(["buck", "kill"], path)


def stop_buckd_for_repo(path: str) -> None:
"""Stop the major buckd instances that are likely to be running for path"""
for project in find_buck_projects_in_repo(path):
Expand Down
4 changes: 3 additions & 1 deletion eden/fs/cli/main.py
Expand Up @@ -21,6 +21,7 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Type

import thrift.transport
from eden.fs.cli.buck import run_buck_command
from eden.fs.cli.telemetry import TelemetrySample
from eden.fs.cli.util import check_health_using_lockfile, wait_for_instance_healthy
from eden.thrift.legacy import EdenClient, EdenNotRunningError
Expand Down Expand Up @@ -402,7 +403,8 @@ def usage_for_redirections(
redirection_repos.add(redir_full_path)
if clean:
print(f"\nReclaiming space from redirection: {redir_full_path}")
subprocess.check_call(["buck", "clean"], cwd=parent)
result = run_buck_command(["buck", "clean"], parent)
result.check_returncode()
print("Space reclaimed.\n")

# Deal with any legacy bind mounts that may have been made
Expand Down

0 comments on commit a46707c

Please sign in to comment.