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

Unable to find Rakefile when running rake ruby_binary #128

Open
robertgates55 opened this issue Apr 8, 2022 · 5 comments
Open

Unable to find Rakefile when running rake ruby_binary #128

robertgates55 opened this issue Apr 8, 2022 · 5 comments

Comments

@robertgates55
Copy link

robertgates55 commented Apr 8, 2022

I'm trying to precompile my assets by creating a ruby_binary that runs rake assets:precompile.

I intend to then tar up the compiled assets and have the genrule output these (rather than test.txt!)

My BUILD goes like this:

ruby_library(
    name = "assets_precompile_lib",
    srcs = glob(
        include = [
            "app/**/*",
            "config/**/*",
            "lib/**/*",
            "vendor/assets/**/*",
        ],
    ) + [
        "Rakefile"
    ],
    deps = [
        "@bundle//:gems",
    ],
)

ruby_binary(
    name = "assets_precompile_bin",
    srcs = [":assets_precompile_lib"],
    args = ["assets:precompile"],
    includes = [
        "src/webapp/Rakefile",
    ],
    main = "@bundle//:bin/rake",
    deps = ["@bundle//:gems"],
)

genrule(
    name = "test",
    srcs = ["Rakefile"],
    outs = ["test.txt"],
    cmd = """
        $(location :assets_precompile_bin)
        echo "test" > $@
    """,
    local = 1,
    message = "test",
    tools = [
        ":assets_precompile_bin",
    ],
    visibility = ["//visibility:public"],
)

But when I run the genrule I get:

➜  bazel build //src/webapp:test
INFO: Analyzed target //src/webapp:test (1 packages loaded, 1740 targets configured).
INFO: Found 1 target...
ERROR: /Users/robert.gates/Repositories/cube/src/webapp/BUILD:698:8: test //src/webapp:test failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument skipped)
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/private/var/tmp/_bazel_robert.gates/dc10ae55cdaa28397da3989c20f911cb/external/bundle/lib/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
Target //src/webapp:test failed to build
Use --verbose_failures to see the command lines of failed build steps.

Could anyone help me understand what's wrong here? I've included the Rakefile in the lib, and also tried getting it onto the LOAD_PATH with includes = but no luck. Any advice really appreciated!

@robertgates55
Copy link
Author

Have simplified the rules to:


ruby_binary(
    name = "assets_precompile_bin",
    srcs = glob(
        include = [
            "app/**/*",
            "config/**/*",
            "lib/**/*",
            "vendor/assets/**/*",
        ],
    ) + [
        "Rakefile",
    ],
    args = [
        "-- assets:precompile",
    ],
    main = "@bundle//:bin/rake",
    deps = [
        "@bundle//:bin",
        "@bundle//:gems",
    ],
)

genrule(
    name = "precompile",
    outs = ["assets.tar.gz"],
    cmd = """
        $(location :assets_precompile_bin)
        echo "test" > $@
    """,
    tools = [
        ":assets_precompile_bin",
    ],
    visibility = ["//visibility:public"],
)

(is that better?)

but get the same error.

@shepting
Copy link

I'm really interested in getting rake to work as well. Subscribing to this ticket.

@kigster
Copy link
Contributor

kigster commented May 12, 2022

Could you try including Rakefile in the include hash instead of appending it afterwards?

@kigster
Copy link
Contributor

kigster commented May 12, 2022

Could you create a branch and add a new folder under examples wjth this test case?

@kigster
Copy link
Contributor

kigster commented May 10, 2023

Looking for additional core maintainers: #146

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

3 participants