I uninstalled Ruby 1.9.3 and installed Ruby 2.0, went and installed the rest-open-uri gem since one of the scripts that I wrote used that gem, but this error occurs when I try to run it
E:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require': E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rest-open-uri-1.0.0/lib/rest-open-uri.rb:413: invalid multibyte escape: /[\r\n\t !#-[]-~\x80-\xff]+|(\[\x00-\x7f])/ (SyntaxError)
Why does this happen? I'm not entirely sure if it's due to me using a newer version of Ruby. The gem was released in 2006 so it is probably outdated and no longer supported.
Other scripts that I have use RestClient, which does not have this problem, so if the best solution is to just drop the outdated libraries and move to newer ones that is probably what I'll do.
One of the differences between ruby 1.9 and ruby 2.0 is that the default encoding is now utf-8. To fix this issue you should edit the file E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rest-open-uri-1.0.0/lib/rest-open-uri.rb, and add the first line:
# encoding: US-ASCII
see here for more details
Related
I have been following "How-to: Use Cucumber with .NET and C# under IronRuby" to set up Cucumber for .net on Windows. I had no problem installing Ruby, IronRuby and installing Cucumber, but when I came to this step, my troubles started:
Check to see if Cucumber under IronRuby works: icucumber –help
Here icucumber.bat is a file we write to tell IronRuby where to find gems. I just copied the script from the link above and changed the directories to match my installation directories.
I first got a bunch of require errors, which I fixed by installing Cucumber (0.6.4) according to "IRONRUBY: 0 TO CUCUMBER IN 15 MINUTES":
IronRuby isn’t quite ready for the latest version of Cucumber.
I also installed term-ansicolor by doing gem install term-ansicolor. At this point, although I got rid of the require errors, I got a new one:
c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/term-ansicolor-1.6.0/lib/term/ansicolor/rgb_triple.rb:8: syntax error, unexpected label
def self.convert_value(color, max: 255)
^
The file is pointing to rgb_triple.rb, which came with the term-ansicolor gem. So I do not understand what could have caused this error.
It seems that IronRuby isn't ready for the last version of term-ansicolor either. Around Ruby 2.0 it became possible to use keyword parameters (the max: 255 part in your error message) but since version 1.9 this can be simulated using hashes.
The last release of IronRuby I can find is 1.1.3 and it claims to be working towards compatibility with Ruby 1.9 but it seems kind of abandoned. So you can downgrade your gems even further or change your Ruby implementation to MRI or JRuby.
I am trying to use Ruby Uglifier gem, but it's giving this warning and the output javascript is not minified:
/usr/lib/ruby/gems/1.8/gems/uglifier-1.2.7/lib/uglifier.rb:51: warning: encoding options not supported in 1.8: r:UTF-8
The easiest answer for this is you need to upgrade to ruby 1.9. 1.8 does not support specifying a character encoding.
Tl;dr
The person who made this gem did not properly specify the supported Ruby versions in their gemspec when they built the gem, so it allowed you to install it, but it will be non-functioning due to the hard coded UTF-8 encoding. You could possibly edit the gem to remove this, but there is no guarantee that it would work, as they may be using UTF-8 specific characters in the gem somewhere. I highly recommend upgrading to 1.9.
I have a Ruby 1.9.2 install on Centos 5.5. Every time I install a gem, I get the error
ERROR: While generating documentation for (gem)
... MESSAGE: U+2018 from UTF-8 to US-ASCII
... RDOC args: lib History.txt README.txt
The gem still installs ok, but there are certain things I can't do. Like use SproutCore, for example. I get this little gem (pun intended).
sc-init xxxx
~ Created directory at xxxx
FATAL ~ invalid byte sequence in US-ASCII
Anyone have any idea what's going on, and how to remedy it? Google isn't much help on this one.
RDoc updated last week, and was supposed to help fix encoding problems.
Try gem update rdoc and see if that helps.
guys. I am developing a Chinese application with rails. Now I want to input some Chinese characters in rails console but cannot do that, either in irb.
Any guys who have the experience to solve this problem? I would appreciate your help!
Based on #Jimmy-Huang's answer, these are the steps I followed on Mac Leopard using rvm and ruby 1.9.2:
rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
That resulted in some errors, particularly when trying bundle install:
uninitialized constant Gem::SilentUI
It turned out that's due to an older version of bundler and this gets rid of it:
gem install bundler
I found the solution for me, it need to re-compile the readline. And now I can input non-ASCII characters!
Because I am using rvm, so I found this article to teach you how to re-compile readline under rvm. http://rvm.beginrescueend.com/packages/readline/
And for someone who is not using rvm, maybe you can follow this post and have a try:
http://henrik.nyh.se/2008/03/irb-readline
By the way, ruby-1.9.2 irb already supports non-ASCII inputing.
Check out the pack method on array:
http://ruby-doc.org/core-1.8.7/classes/Array.html#M000287
I think you'd want:
[111 ,222, 333].pack(U*)
Here is an interesting discussion on the subject had with Matz:
http://www.ruby-forum.com/topic/134919
I'm using Ruby 1.9.2 (Yarv).
When I install gems I just use "gem install ".
How can I know which Ruby version they are written in: 1.8.7, 1.9.1 or 1.9.2?
If I'm using the latest version and I install a gem that is written in 1.8.7, then that gem doesn't work?
Eg. Yardstick gem seems to not work with 1.9.2 but perfectly with 1.8.7.
How do you check what version each gem is using?
Could someone enlighten this topic for me.
Unfortunatelly there is no definitive way to check that as there are so many versions and variants or Ruby interpreters (Ruby, JRuby, Iron Ruby) and system platforms. Also one gem which is pure Ruby may not work on all platforms with same interpereter verson, because some OS specific properties could be used.
So you must trust the autor or docs he/she provided. Another way to make sure that your platform is right for gem just run tests enclosed to gem - every well written gem should have such.
There is also small tip: if file contains
# -*- encoding: utf-8 -*-
then autor probably developed the gem with 1.9.x in mind.
There's a website for answering the question: "Is it Ruby 1.9?"
http://isitruby19.com/
It doesn't look like anyone has reported on Yardstick yet:
http://isitruby19.com/yardstick
You could be the first, and report that it's broken in 1.9.