Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private method `define_method' called for Dir:Class (NoMethodError) #74

Closed
lalten opened this issue Jul 2, 2020 · 1 comment
Closed

Comments

@lalten
Copy link
Contributor

lalten commented Jul 2, 2020

Hi, I'm trying to use CMock's cmock.rb with rules_ruby.

I have the WORKSPACE set up as per the rules_ruby readme instructions.

cmock.rb is visible as target autogen

ruby_binary(
    name = "autogen",
    main = "lib/cmock.rb",
    srcs = glob(["**/*"]),
)

I'm calling this autogen target in a custom Bazel rule that basically does this:

...
    autogen_exe = ctx.attr.cmock_autogen.files.to_list()[0]
    ctx.actions.run(
        inputs = ctx.files.headers_to_be_mocked + ctx.files.cmock_config,
        outputs = generated_files,
        arguments = ["-o", ctx.file.cmock_config.path] + [file.path for file in ctx.files.headers_to_be_mocked],
        executable = autogen_exe,
    )
...

But there seem to be errors in rules_ruby's wrapper script

bazel-out/k8-opt/bin/external/CMock/autogen:121: warning: string literal in condition
bazel-out/k8-opt/bin/external/CMock/autogen:122: warning: string literal in condition
bazel-out/k8-opt/bin/external/CMock/autogen:26:in `<main>': private method `define_method' called for Dir:Class (NoMethodError)
Did you mean?  define_singleton_method
Target //(redacted) failed to build

I tried with ruby 2.3 (host ruby) and 2.7.0.

I also tried to use the commit before 5a81b11 (and set up the WORKSPACE as explained in that version's readme) but it has other problems:

bazel-out/k8-opt/bin/external/CMock/autogen:113: warning: string literal in condition
bazel-out/k8-opt/bin/external/CMock/autogen:114: warning: string literal in condition
bazel-out/k8-opt/bin/external/CMock/autogen:39:in `find_runfiles': Cannot find .runfiles directory for bazel-out/k8-opt/bin/external/CMock/autogen (RuntimeError)
        from bazel-out/k8-opt/bin/external/CMock/autogen:103:in `main'
        from bazel-out/k8-opt/bin/external/CMock/autogen:146:in `<main>'
Target //(redacted) failed to build

Am I doing something wrong? Any ideas how to fix this?

@lalten
Copy link
Contributor Author

lalten commented Jul 3, 2020

It seems this is caused by ctx.action.run always using system ruby (2.3), which is too old on this system (Ubuntu 16.04). Closing as duplicate of #63

@lalten lalten closed this as completed Jul 3, 2020
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

No branches or pull requests

1 participant