sematic icon indicating copy to clipboard operation
sematic copied to clipboard

CLI should switch cwd to source dir when ran by Bazel

Open tscurtu opened this issue 2 years ago • 0 comments

CLI commands sometimes perform file operations. When ran by Bazel, the cwd is changed to the bazel runtime dir, so relative file paths don't work as intended, and we end up with special treatment like:

    # make sure the file is created in the workspace, and not in the bazel runtime dir
    if not os.path.isabs(file):
        workspace = os.getenv("BUILD_WORKSPACE_DIRECTORY")
        if workspace is not None:
            file = os.path.join(workspace, file)

Always make the CLI switch the cwd to the Bazel root source dir when execute by Bazel, and test that all CLI commands still work as expected.

tscurtu avatar Jan 13 '23 17:01 tscurtu