This error had been occurred when I tried to run time_math2.
To reproduce
git clone https://github.com/zverok/time_math2
cd time_math2
bundle
bundle exec rspec
Error:
An error occurred while loading ./spec/spec_helper.rb.
Failure/Error: require 'simplecov'
NotImplementedError:
Method $RS is already a global not implemented
# ~/.rubies/truffleruby-1.0.0-rc12/lib/mri/English.rb:79:in `<top (required)>'
# ~/.gem/truffleruby/2.4.4/gems/simplecov-0.16.1/lib/simplecov.rb:3:in `require'
# ~/.gem/truffleruby/2.4.4/gems/simplecov-0.16.1/lib/simplecov.rb:3:in `<top (required)>'
# ./spec/spec_helper.rb:1:in `require'
# ./spec/spec_helper.rb:1:in `<top (required)>'
This also happens with RuboCop apparently:
https://travis-ci.org/eregon/cancancan/jobs/497486197
$ bundle exec rubocop && bundle exec rake
bundler: failed to load command: rubocop (/home/travis/build/eregon/cancancan/gemfiles/vendor/bundle/truffleruby/2.4.0/bin/rubocop)
NotImplementedError: Method $INPUT_RECORD_SEPARATOR is already a global not implemented
/home/travis/.rvm/rubies/truffleruby-1.0.0-rc12/lib/mri/English.rb:84:in `<top (required)>'
/home/travis/build/eregon/cancancan/gemfiles/vendor/bundle/truffleruby/2.4.0/gems/rubocop-0.59.2/lib/rubocop.rb:6:in `require'
I'm not sure what defines $RS/$INPUT_RECORD_SEPARATOR.
Here is a very simple repro case, but it might be different because there it's just using defining twice the aliases:
ruby -rEnglish -e 'load $".grep(/English/).first'
Supporting an alias already present might be a good workaround.
@eregon
$RS => $/ <= https://github.com/ruby/ruby/blob/trunk/lib/English.rb#L79
$INPUT_RECORD_SEPARATOR => $/ <= https://github.com/ruby/ruby/blob/trunk/lib/English.rb#L84
In my case, this happens because cancancan.gemspec contains:
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cancan/version'
Gem::Specification.new do |s|
...
s.files = `git ls-files lib init.rb cancancan.gemspec`.split($INPUT_RECORD_SEPARATOR)
...
end
But $INPUT_RECORD_SEPARATOR doesn't exist yet, and so is nil on both MRI and TruffleRuby (an unintended result in that gemspec that works accidentally as split(nil) works).
So an easy reproducer for that case is:
jt ruby -e 'p $INPUT_RECORD_SEPARATOR; require "English"'
This more complex case also works on MRI:
$ ruby -w -e '$INPUT_RECORD_SEPARATOR=42; p $INPUT_RECORD_SEPARATOR; p $/; require "English"; p $INPUT_RECORD_SEPARATOR; p $/; $INPUT_RECORD_SEPARATOR="3"; p $/'
42
"\n"
"\n"
"\n"
"3"
Where the alias basically overrides the old global variable value, and make them forever aliased to each other.
I'll work on a fix for this.
@deepj Thanks for the report, cb4c8a9d6ba7e15817b1126778f5fff9ac0239a9 should fix and allow unrestricted aliasing of global variables like in MRI. It will be in the next release.
I verified, and the specs of time_math2 now all pass :smiley:
$ bundle exec rspec
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*...........................................................................
Pending: (Failures listed here are expected and do not affect your suite's status)
1) TimeMath::Units::Base math with Date #advance non-integer advance
# Temporarily skipped with xit
# ./spec/time_math/units/base_spec.rb:210
Finished in 10.79 seconds (files took 4.91 seconds to load)
651 examples, 0 failures, 1 pending
Coverage report generated for RSpec to /home/eregon/code/time_math2/coverage. 326 / 337 LOC (96.74%) covered.
[Coveralls] Outside the CI environment, not sending data.
bundle exec rspec 61.19s user 0.99s system 278% cpu 22.329 total
cc @zverok, in the case you would want to add rvm: - truffleruby in the .travis.yml (when 1.0.0-rc15 is released).
Will do :)
(Well, obviously this $RS trick is outdated as hell, I just once in a past copied it into my default .gemfile template and haven't rethought it since.)
Thanks for all the great work you are doing here!
TruffleRuby 1.0.0-rc15 was released with this fix.