Skip to content

CLI option for override steep command at spawn worker#511

Merged
soutaro merged 3 commits intosoutaro:masterfrom
matsubara0507:specify-steep-command-opt
Mar 18, 2022
Merged

CLI option for override steep command at spawn worker#511
soutaro merged 3 commits intosoutaro:masterfrom
matsubara0507:specify-steep-command-opt

Conversation

@matsubara0507
Copy link
Contributor

I think to execute Steep with Bazel and rules_ruby.
So, I writen Bazel configuration as follows.

ruby_test(
    name = "typecheck",
    main = "@bundle_example//:bin/steep",
    args = [
        "check",
        "--steepfile=example/Steepfile",
    ],
    srcs = ["Steepfile", ":lib"] + glob(["sig/**/*.rbs"]),
    deps = [":lib", "@bundle_example//:bin"],
)

But, bazel test is failed.

# Type checking files:

#<Errno::ENOENT: No such file or directory - steep>
  /.rbenv/versions/3.1.1/lib/ruby/3.1.0/open3.rb:222:in `spawn'
  /.rbenv/versions/3.1.1/lib/ruby/3.1.0/open3.rb:222:in `popen_run'
  /.rbenv/versions/3.1.1/lib/ruby/3.1.0/open3.rb:161:in `popen2'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:36:in `spawn_worker'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:47:in `block in spawn_typecheck_workers'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:46:in `times'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:46:in `each'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:46:in `map'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/server/worker_process.rb:46:in `spawn_typecheck_workers'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/drivers/check.rb:38:in `run'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/cli.rb:115:in `process_check'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/lib/steep/cli.rb:52:in `run'
  /external/bundle_example/lib/ruby/3.1.0/bundler/gems/steep-64ced3af5657/exe/steep:11:in `<top (required)>'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/bin/steep:14:in `load'
  /execroot/rules_steep/bazel-out/darwin-fastbuild/bin/example/typecheck-test.runfiles/bundle_example/bin/steep:14:in `<main>'

Bazel is execute main wrapped by Ruby script instead of directly main executed.
And, Bazel is not set path of main to PATH environment variable in sandbox.
Therefore, Steep cannot spawn worker using Open3.popen2("steep", ...).

To solve this issue, add --steep-command option for specify command to spawn worker.
Rewrite Bazel configuration above using --steep-command option as follows then I could execute Steep with Bazel.

ruby_test(
    name = "typecheck",
    main = "@bundle_example//:bin/steep",
    args = [
        "check",
        "--steepfile=example/Steepfile",
        "--steep-command=example/typecheck", # this is Ruby script wrapped `main`
    ],
    srcs = ["Steepfile", ":lib"] + glob(["sig/**/*.rbs"]),
    deps = [":lib", "@bundle_example//:bin"],
)

I think that need --steep-command option to execute Steep with Bazel.
But, I have not idea other use-case...

Copy link
Owner

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🎉

@soutaro soutaro merged commit db81aae into soutaro:master Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants