Can I use Ruby gems in Opal?
opalrb, ruby, rubygems
Solution
You can add a gem's `lib` path to Opal load paths by using `Opal.use_gem`
Common pitfalls are:
- use of String mutability
- relying on the difference between String and Symbol
- shelling out (
Available tools to fix/workaround some of those issues are:
- stubbing files `Opal::Processor.stub_file('fileutils')`
- hiding code branches at compile time using `RUBY_ENGINE`, example: ` unless RUBY_ENGINE == 'opal' unparsable/breaking code here end `
You can look at the `opal-rspec` source code to see this stuff in action:
https://github.com/opal/opal-rspecProblem
There's `opal-irb` and `opal-jquery` and `vienna` but is there any way to use gems directly in the browser via Opal?