为什么Bazel run_shell没有正确放置参数?

为什么Bazel run_shell没有正确放置参数?,bazel,bazel-rules,Bazel,Bazel Rules,我有一条规则a: def _a_impl(ctx): src = ctx.actions.declare_file("src.txt") ctx.actions.write(src, "nothin") dst = ctx.actions.declare_file("dst.txt") ctx.actions.run_shell( outputs = [dst], inputs = [src], command =

我有一条规则
a

def _a_impl(ctx):
    src = ctx.actions.declare_file("src.txt")
    ctx.actions.write(src, "nothin")
    dst = ctx.actions.declare_file("dst.txt")
    ctx.actions.run_shell(
        outputs = [dst],
        inputs = [src],
        command = "cp",
        arguments = [src.path, dst.path]
    )
    return [DefaultInfo(files = depset([dst]))]

a = rule(
    implementation = _a_impl,
)
由于某些原因,我得到以下错误:

ERROR: /home/erran/example/out_dir/BUILD:9:1: error executing shell command: '/bin/bash -c cp  bazel-out/k8-fastbuild/bin/src.txt bazel-out/k8-fastbuild/bin/dst.txt' failed (Exit 1) bash failed: error executing command /bin/bash -c cp '' bazel-out/k8-fastbuild/bin/src.txt bazel-out/k8-fastbuild/bin/dst.txt
看起来Bazel没有正确解析参数。如您所见,实际的bash命令尝试
cp'

我还尝试格式化copy命令本身,效果很好:

ctx.actions.run_shell(
    outputs = [dst],
    inputs = [src],
    command = "cp {} {}".format(src.path, dst.path)
)
有人知道问题出在哪里吗?

这是将字符串传递给
命令的
参数
run\u shell
。像这样的方法应该会奏效:

    ctx.actions.run_shell(
        outputs = [dst],
        inputs = [src],
        command = "cp $1 $2",
        arguments = [src.path, dst.path]
    )