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

Possible issue with calling .color #1839

Closed
justin808 opened this issue Apr 27, 2015 · 5 comments
Closed

Possible issue with calling .color #1839

justin808 opened this issue Apr 27, 2015 · 5 comments
Labels

Comments

@justin808
Copy link

For some reason, gems that include rainbow, like RuboCop, are failing when used with Ruby 2.2.1. This might be a bug with Ruby's 2.2.x refinements feature.

private method `color' called for "An error occurred while Style/MultilineOperationIndentation":String
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/rubocop-0.30.1/lib/rubocop/cop/team.rb:93:in `block (2 levels) in process_commissioner_errors'

UPDATE

Actually, I'm seeing this with Ruby 2.1.5. Researching.

@justin808 justin808 changed the title Possible issue with 2.2.1 and refinements Possible issue with calling .color Apr 27, 2015
@justin808
Copy link
Author

This is caused when both "rainbow" and "colorize" gems are used. Avoid using both as both monkey patch String, and colorize puts a private method on String called color.

https://github.com/fazibear/colorize/blob/master/lib/colorize/instance_methods.rb

@justin808 justin808 reopened this Apr 27, 2015
@justin808
Copy link
Author

According to ku1ik/rainbow#25 (comment), the Rainbow gem does not automatically monkey patch string.

Reopening this issue in case this would be a nice enhancement for Rubocop.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 29, 2015

So, your project is using colorize and this is somehow conflicting with rainbow, right? I'll have to check the code, but I think we dropped the monkey patching when we adopted rainbow 2.

@justin808
Copy link
Author

@bbatsov We switched to avoid the issue, but it's a serious yak shaver for those that are not expecting it! I'm 100% the monkey patching is being done. I could also be that colorize is doing the monkey patching, and RuboCop is crashing due that.

@bbatsov
Copy link
Collaborator

bbatsov commented May 1, 2015

@bbatsov bbatsov added the bug label May 16, 2015
@bbatsov bbatsov closed this as completed in cd68448 Sep 3, 2015
bbatsov added a commit that referenced this issue Sep 3, 2015
[Fix #1839] Remove Rainbow string monkey patching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants