Giter Site home page Giter Site logo

Comments (12)

cccclai avatar cccclai commented on June 2, 2024

Thank you for trying it out! @dbort any idea for this error?

from executorch.

gochaudhari avatar gochaudhari commented on June 2, 2024

@cccclai, I just checked the environment variable in my python script and it shows empty. When I add this " os.putenv("HOME", "/usr/home")" to my run function my problem is solved.

class Buck2Runner:
def init(self, tool_path: str) -> None:
self._path = tool_path

def run(self, args: Sequence[str]) -> list[str]:
    """Runs buck2 with the given args and returns its stdout as a sequence of lines."""
    os.putenv("HOME", "/usr/home")
    try:
        cp: subprocess.CompletedProcess = subprocess.run(
            [self._path] + args, capture_output=True, cwd=BUCK_CWD, check=True
        )
        return [line.strip().decode("utf-8") for line in cp.stdout.splitlines()]
    except subprocess.CalledProcessError as ex:
        raise RuntimeError(ex.stderr.decode("utf-8")) from ex

Do you have any suggestions on this?

from executorch.

dbort avatar dbort commented on June 2, 2024

Thanks for reporting this issue. Must've been caused by this logic that I added to make things work in the CI jobs:

executorch/setup.py

Lines 494 to 498 in 3a2b2e8

# This script is sometimes run as root in docker containers. buck2
# doesn't allow running as root unless $HOME is owned by root or
# does not exist. So temporarily undefine it while configuring
# cmake, which runs buck2 to get some source lists.
old_home = os.environ.pop("HOME", None)

The question is why it's happening for you but not for other users, and not for the CI jobs. The buck2 check itself is at https://github.com/facebook/buck2/blob/ad891c4934458a461b5fcf375e2c17302df00c0d/app/buck2_common/src/invocation_roots.rs#L125, which was added in the buck2 2023-08-15 release, which should be part of the 2024-02-15 release that executorch uses (https://github.com/pytorch/executorch/blob/main/.ci/docker/ci_commit_pins/buck2.txt).

To unblock yourself quickly, you could make a local change that removes this logic:

--- a/setup.py
+++ b/setup.py
@@ -490,17 +490,8 @@ class CustomBuild(build):
         if not self.dry_run:
             # Dry run should log the command but not actually run it.
             (Path(cmake_cache_dir) / "CMakeCache.txt").unlink(missing_ok=True)
-        try:
-            # This script is sometimes run as root in docker containers. buck2
-            # doesn't allow running as root unless $HOME is owned by root or
-            # does not exist. So temporarily undefine it while configuring
-            # cmake, which runs buck2 to get some source lists.
-            old_home = os.environ.pop("HOME", None)
-            # Generate the build system files.
-            self.spawn(["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args])
-        finally:
-            if old_home is not None:
-                os.environ["HOME"] = old_home
+        # Generate the build system files.
+        self.spawn(["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args])
 
         # Build the system.
         self.spawn(["cmake", "--build", cmake_cache_dir, *build_args])

The real fix is to stop running the jobs as root (pytorch/test-infra#5091). But I could at least reduce the blast radius of this hack by only removing the HOME definition when running as root. And ultimately we want to remove buck2 from this flow altogether.

from executorch.

dbort avatar dbort commented on June 2, 2024

@gochaudhari if you have a chance, could you try patching in #3507 to see if it fixes the problem for you?

from executorch.

gochaudhari avatar gochaudhari commented on June 2, 2024

@dbort I tried it just now. It is working for me. However, I am not running it as a root user.

from executorch.

dbort avatar dbort commented on June 2, 2024

@gochaudhari Great, thanks for checking! Don't worry about running as root, I'm testing that elsewhere. My main goal was to make sure that this fixes your problem.

from executorch.

dbort avatar dbort commented on June 2, 2024

I've merged the fix into main, and it should also be available in the upcoming v0.2.1 patch release. Thank you @gochaudhari for reporting this bug and for helping me validate the fix!

from executorch.

gochaudhari avatar gochaudhari commented on June 2, 2024

Thank @dbort and @cccclai for the fix.

from executorch.

leigao97 avatar leigao97 commented on June 2, 2024

I have the same issue when I submodule executorch and run cmake from the subpath. It works fine if I directly clone executorch and run cmake from there.

from executorch.

dbort avatar dbort commented on June 2, 2024

I have the same issue when I submodule executorch and run cmake from the subpath. It works fine if I directly clone executorch and run cmake from there.

@leigao97 Does this happen to you in the main branch? Which executorch git hash are you synced to when this happens?

from executorch.

leigao97 avatar leigao97 commented on June 2, 2024

I am using the main branch. I think I found the reason. The path or the parent folder should not have the character "-" or maybe other ones like "." as I saw the same problem from #3524. Once I rename the parent folder, buck2 works.

from executorch.

dbort avatar dbort commented on June 2, 2024

Wow weird, thanks for tracking that down @leigao97 ! Good to know: this sounds like some unusual buck2 behavior.

from executorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.