-
Notifications
You must be signed in to change notification settings - Fork 10
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
Provide a hermetic bundle command #41
Comments
I see that the interpreter ships with a gem binary so I think this is pretty simple, we just need an |
Gem is not used to install dependencies in Gemfile/Gemfile.lock. Instead, one should use the following:
This doesn't work at the moment though, I'll fix it. |
Existing documentation tells developers to run |
OH I see, it really doesn't, rails is just doing something sneaky to run it later? From that link
|
Yes, installing Rails gem globally in this manual is just to make a |
I just tested and the following works:
I've seen issues doing this on JRuby, but it works fine on MRI. |
That feels like a bootstrap issue, how would I get a Similarly, if I'm in a state where |
@alexeagle Yes, we should still expose |
@alexeagle Are there any great examples of rulesets exposing interpreter binaries? In case of Ruby, we cannot simply export |
I don't have examples off-hand, but I've usually seen tools exposed exposed as #48 seems to have gotten rid of support for this
but that doesn't seem supported anymore. For those following along and wanting the tool to be exposed, I got it working by digging for the target corresponding to the binary and wrapping it into a script to jump out of the sandbox: BUILD
sh_binary(
name = "bundle",
srcs = ["jump_script.sh"],
# Version grabbed from `bazel query "@bundle//:*"`
data = ["@bundle//:bundler-2.2.33"],
args = ["$(locations @bundle//:bundler-2.2.33)"],
) jump_script.sh
#!/bin/bash
# Grabs a hermetically installed tool and hops back into the workspace
# Borrowed from https://stackoverflow.com/a/72816931
set -e
LAUNCH_WORKING_DIRECTORY=$(pwd)
if test "${BUILD_WORKING_DIRECTORY+x}"; then
cd $BUILD_WORKING_DIRECTORY
fi
# I can't figure out a way to deal with needing `$locations` over `$location`, so the final path is hardcoded + the number of arguments to skip (1 extra path) is hardcoded
$LAUNCH_WORKING_DIRECTORY/$1/bin/bundle "${@:3}" which lets me know run (or wrap into a separate script) |
Indeed it no longer works, though for a transition period, you could still use
Thanks for sharing, I'll see if I could generalize this solution. |
I managed to have binaries for the toolchain (
I'm yet to make binaries work for |
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby -- -e "puts 123" -> evaluate Ruby script bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby -- -e "puts 123" -> evaluate Ruby script bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby -- -e "puts 123" -> evaluate Ruby script bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby -- -e "puts 123" -> evaluate Ruby script bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
This allows to use gems installed in toolchain directly. It works by running binaries with `bazel run @ruby//:<binary>`. Some examples: bazel run @ruby -- -e "puts 123" -> evaluate Ruby script bazel run @ruby//:bundle -- update -> update gems in Gemfile.lock bazel run @ruby//:bundle -- add rails -> add Rails gem to Gemfile bazel run @ruby//:gem -- install rails -> install Rails gem to the toolchain bazel run @ruby//:rails -- new $(pwd)/my_app -> create Rails application to ./my_app directory Fixes #41
Without installing any ruby stuff on my machine, I'd like to be able to edit the
Gemfile
andGemfile.lock
files in a correct way by running sth likebazel run @ruby//:gem -- install rails
, without worrying about version skew with a different version of gem than Bazel will use.The text was updated successfully, but these errors were encountered: