buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

cannot run unused_deps via bazel run

Open yishanhe opened this issue 4 years ago • 0 comments

unused_deps assumes that the cmd will be ran in a folder path contains WORKSPACE

Thus we cannot run it via bazel run like below

➜ bazel run //tools/linter:unused_deps //...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //tools/linter:unused_deps (26 packages loaded, 239 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_yshanhe/1fbe1deddbb025302cb8f41334c1dd8a/sandbox
Target //tools/linter:unused_deps up-to-date:
  bazel-bin/tools/linter/unused_deps
INFO: Elapsed time: 10.684s, Critical Path: 0.05s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
2020/10/09 09:36:33 running: bazel query --tool_tag=unused_deps --keep_going --color=yes --curses=yes kind('(java|android)_*', //...)
ERROR: The 'query' command is only supported from within a workspace (below a directory having a WORKSPACE file).
See documentation at https://docs.bazel.build/versions/master/build-ref.html#workspace
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
2020/10/09 09:36:34 exit status 2
found no targets of kind (java|android)_*
usage: unused_deps TARGET...

For Java rules in TARGETs, prints commands to delete deps unused at compile time.
Note these may be used at run time; see documentation for more information.

We are hoping we can add a flag for example workspace, to give a root dir contains the WORKSPACE file.

bazel run :unused_deps-darwin -- --workspace="/you/proj/roo/dir/" //...l

I have a patch for this, but I would like to bring this first to have a discussion.

Thanks,

Shanhe

yishanhe avatar Oct 09 '20 16:10 yishanhe