Skip to content

Commit 719fe52

Browse files
authored
Merge pull request #181 from ruby/schneems/rubyopt-binstubs
Introduce binstubs to set RUBYOPT for development
2 parents eab40be + 3420937 commit 719fe52

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
ruby-version: ${{ matrix.ruby }}
4141
bundler-cache: true
4242
- name: test
43-
run: RUBYOPT="--disable=syntax_suggest" bundle exec rake test
43+
run: bin/rake test
4444
continue-on-error: ${{ matrix.ruby == 'head' }}

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,20 @@ Any other entrypoints are subject to change without warning. If you want to use
180180

181181
## Development
182182

183-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
183+
### Handling conflicts with the default gem
184184

185-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
185+
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.).
186+
187+
There are some binstubs that already have this done for you. Instead of running `bundle exec rake` you can run `bin/rake`. Binstubs provided:
188+
189+
- `bin/rake`
190+
- `bin/rspec`
191+
192+
### Installation
193+
194+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
195+
196+
To install this gem onto your local machine, run `bin/rake install`. To release a new version, update the version number in `version.rb`, and then run `bin/rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
186197

187198
### How to debug changes to output display
188199

bin/rake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Make sure syntax_suggest default gem is not loaded first
5+
RUBYOPT="${RUBYOPT-} --disable=syntax_suggest"
6+
RUBYOPT="$RUBYOPT" bundle exec rake "$@"

bin/rspec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Make sure syntax_suggest default gem is not loaded first
5+
RUBYOPT="${RUBYOPT-} --disable=syntax_suggest"
6+
RUBYOPT="$RUBYOPT" bundle exec rspec "$@"

0 commit comments

Comments
 (0)