From d2eef4b7867578df302cfa9d7c97eebbef8d9ee4 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 16 Mar 2023 20:45:18 -0500 Subject: [PATCH] [ruby/syntax_suggest] Introduce binstubs to set RUBYOPT for development Because `syntax_suggest` is a default gem you can get conflicts when working on this project with Ruby 3.2+. To fix conflicts you can disable loading `syntax_suggest` as a default gem by using then environment variable `RUBYOPT` with the value `--disable=syntax_suggest`. The `RUBYOPT` environment variable works the same as if we had entered those flags directly in the ruby cli (i.e. `ruby --disable=syntax_suggest` is the same as `RUBYOPT="--disable=syntax_suggest" ruby`). It's needed because we don't always directly execute Ruby and RUBYOPT will be picked up when other commands load ruby (`rspec`, `rake`, or `bundle` etc.). There are some binstubs that already have this done for you. Instead of running `bundle exec rake` you can run `bin/rake`. Binstubs provided: - `bin/rake` - `bin/rspec` https://github.com/ruby/syntax_suggest/commit/342093706d --- bin/rake | 6 ++++++ bin/rspec | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100755 bin/rake create mode 100755 bin/rspec diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..4687d84cc3 --- /dev/null +++ b/bin/rake @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Make sure syntax_suggest default gem is not loaded first +RUBYOPT="${RUBYOPT-} --disable=syntax_suggest" +RUBYOPT="$RUBYOPT" bundle exec rake "$@" diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000000..a0c785c220 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Make sure syntax_suggest default gem is not loaded first +RUBYOPT="${RUBYOPT-} --disable=syntax_suggest" +RUBYOPT="$RUBYOPT" bundle exec rspec "$@"