Skip to content
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

English: Method $RS is already a global not implemented #1590

Closed
deepj opened this issue Feb 23, 2019 · 8 comments
Closed

English: Method $RS is already a global not implemented #1590

deepj opened this issue Feb 23, 2019 · 8 comments
Assignees
Milestone

Comments

@deepj
Copy link

deepj commented Feb 23, 2019

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)>'
@eregon
Copy link
Member

eregon commented Feb 23, 2019

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'

@eregon
Copy link
Member

eregon commented Feb 23, 2019

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.

@deepj
Copy link
Author

deepj commented Feb 23, 2019

@eregon
Copy link
Member

eregon commented Feb 25, 2019

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.

@eregon eregon self-assigned this Feb 25, 2019
@eregon eregon added this to the 1.0.0-rc15 milestone Mar 22, 2019
@eregon
Copy link
Member

eregon commented Mar 22, 2019

@deepj Thanks for the report, cb4c8a9 should fix and allow unrestricted aliasing of global variables like in MRI. It will be in the next release.

@eregon eregon closed this as completed Mar 22, 2019
@eregon
Copy link
Member

eregon commented Mar 22, 2019

I verified, and the specs of time_math2 now all pass 😃

$ 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).

@zverok
Copy link

zverok commented Mar 30, 2019

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!

@eregon
Copy link
Member

eregon commented Apr 10, 2019

TruffleRuby 1.0.0-rc15 was released with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants