Giter Club home page Giter Club logo

rules_ruby's People

Contributors

alexeagle avatar jgao54 avatar p0deje avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rules_ruby's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

bazel
WORKSPACE
  • io_bazel_stardoc 0.5.3
  • aspect_bazel_lib v2.0.3
  • io_bazel_rules_go v0.43.0
  • bazel_gazelle v0.34.0
  • bazel_skylib_gazelle_plugin 1.5.0
  • buildifier_prebuilt 6.4.0
bazel-module
MODULE.bazel
bazelisk
.bazelversion
  • bazel 6.4.0
github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • mxschmitt/action-tmate v3
  • actions/checkout v4
  • p0deje/setup-bazel 0.3.2
  • ruby/setup-ruby v1
  • mxschmitt/action-tmate v3
  • bazel-contrib/.github v5

  • Check this box to trigger a request for Renovate to run again on this repository

Only download gems needed for the targets I request

Note, this is "nice to have", maybe not a requirement for a 1.0 of rules_ruby.

Use case: I'm in a monorepo where one app has 1000 giant dependencies. I write a little ruby tool for all developers to run, and it only needs one small gem, call it "mygem".

I don't want users of my tool to have to wait to download all the giant dependencies. So the bundler install would have to be decomposed such that each gem goes in its own external/ repository, and then in my BUILD files instead of depending on "all gems" like @bundler//:all, I would depend on @bundler_mygem. That way the other gems aren't referenced in the build graph and so they aren't fetched.

Support bzlmod

Bazel 7 will be released in the next few weeks and enables bzlmod by default.

These rules should be tested with bzlmod and be published to the Bazel Central Registry with each release.

Failure compiling MRI

Have you seen something like this?

This error feels to me like the repository rule is trying to write to some global location on my disk, and maybe we need to set an environment variable like XRUBY_RUBYLIBDIR somewhere so the MRI build process is okay with running in some read-only sandbox?

I'm on Linux, tried ruby 3.0.6 and 3.2.2, get an error like the following

x86_64-linux-fake.rb updated
external command failed with status 2

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0  7329k      0  0:00:02  0:00:02 --:--:-- 7329k
./tool/mkconfig.rb:272:in `write': Permission denied @ io_write - <STDOUT> (Errno::EACCES)
        from ./tool/mkconfig.rb:272:in `print'
        from ./tool/mkconfig.rb:272:in `<main>'
make: *** [uncommon.mk:879: .rbconfig.time] Error 1
make: *** Waiting for unfinished jobs....

BUILD FAILED (Ubuntu 20.04 on x86_64 using ruby-build 20231114)

I do have a system ruby already

$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

Tech debt: CI bzlmod testing ignores ruby_version.bzl

Currently the approach for testing different interpreters is for CI to Run echo 'RUBY_VERSION = "3.1.4"' > ruby_version.bzl but under MODULE.bazel this .bzl file cannot be load()ed, so we have a fixed interpreter version.

Provide a hermetic bundle command

Without installing any ruby stuff on my machine, I'd like to be able to edit the Gemfile and Gemfile.lock files in a correct way by running sth like bazel run @ruby//:gem -- install rails, without worrying about version skew with a different version of gem than Bazel will use.

Document how to use "pre-built binary" gems to avoid install-time non-hermeticity

The psych gem (version 5.1.1.1) fails to install on my machine, log contains:

conftest.c:3:10: fatal error: yaml.h: No such file or directory
    3 | #include <yaml.h>
      |          ^~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <yaml.h>
/* end */

As documented here, for example
https://github.com/sparklemotion/nokogiri#native-gems-faster-more-reliable-installation
there's a way to start from a pre-compiled native gem instead. I think most Bazel users should be using this to achieve reproducible builds.

(Of course, you could also imagine a cc_library to build the C extension, but then we're swapping out part of the bundle installer which is a bigger project)

bundler downloads gem dependencies rather than Bazel downloader

Ideally the ruleset should use rctx.download[_and_extract] to fetch dependency gems so that:

  • they are cached in the bazel repository cache
  • configuration of the Bazel downloader can be used, i.e. to ensure they are fetched from a corporate proxy
  • bazel shows more information about the fetching phase than just "running bundler"
  • we can apply patches to third-party gems in a similar way as other bazel fetches may be patched

rb_download eagerly download ruby toolchain

I noticed that when running bazel build //some/non/ruby/target, the ruby interpreter is always downloaded even if the target does not depends on it.

It looks like rb_download always performs the download before registering the toolchain. I believe this is different from the recommended bazel toolchain setup, which only downloads the toolchain on a per-need basis (i.e. if rb_* rules are in the build action graph).

non-hermetic bundle install

bundle install passes in PATH variable, which can head to non-hermetic builds.

In our case, we had $GEM_HOME/bin:$BUNDLE_PATH/gems/bin: in our PATH variable that resulted in gems getting downloaded in a different directory.

May be better to remove PATH altogether.

rb_binary should work as the tool in a run_binary

The runfiles produced by an rb_binary target ought to be self-contained, so that binary can be used as the tool in a subsequent action that uses a Ruby program to transform some input files into files under bazel-out.

I think this is currently not working, here's a PR with a demo that I'd expect to work:
#15

`rb_binary` does not work unless Gemfile is listed as transitive srcs

Current rb_binary implementation depends on Gemfile to be listed as a transitive source in order to set BUNDLE_GEMFILE env var. This is not super obvious. Given that we have already specified Gemfile in rb_bundle, a more explicit way to express this could be introducing a link_bundle_gems function for this, something like:

load("@bundle//:defs.bzl", "link_bundle_gems")
link_bundle_gems(name = "gems")

rb_binary(
    name = "add-numbers",
    args = ["1"], 
    main = "add.rb",
    deps = [
         ":gems",
    ],
)

Support custom bundler version

Is there a way to support installing a specific version of bundler when setting up the ruby toolchain? Currently this is not configurable, afaik; instead the default version of bundler corresponding to the ruby version is used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.