The third line in my ruby script
# encoding: utf-8
require "mail"
results in the following error
/usr/local/share/gems1.9/gems/json-1.8.1/lib/json/pure/parser.rb:242:in `rescue in parse_string': Caught Encoding::CompatibilityError at '[{"content-type":"ap': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (JSON::ParserError)
from /usr/local/share/gems1.9/gems/json-1.8.1/lib/json/pure/parser.rb:213:in `parse_string'
from /usr/local/share/gems1.9/gems/json-1.8.1/lib/json/pure/parser.rb:257:in `parse_value'
from /usr/local/share/gems1.9/gems/json-1.8.1/lib/json/pure/parser.rb:121:in `parse'
from /usr/local/share/gems1.9/gems/json-1.8.1/lib/json/common.rb:155:in `parse'
from /usr/local/share/gems1.9/gems/json-1.8.1/lib/json/common.rb:334:in `load'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types/loader.rb:210:in `load_from_json'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types/loader.rb:61:in `block in load_json'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types/loader.rb:60:in `each'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types/loader.rb:60:in `load_json'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types/loader.rb:87:in `load'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types.rb:280:in `load_default_mime_types'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types.rb:307:in `<class:Types>'
from /usr/local/share/gems1.9/gems/mime-types-2.3/lib/mime/types.rb:62:in `<top (required)>'
from /usr/local/share/ruby19/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/ruby19/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/gems1.9/gems/mail-2.6.1/lib/mail.rb:9:in `<module:Mail>'
from /usr/local/share/gems1.9/gems/mail-2.6.1/lib/mail.rb:2:in `<top (required)>'
from /usr/local/share/ruby19/site_ruby/rubygems/core_ext/kernel_require.rb:135:in `require'
from /usr/local/share/ruby19/site_ruby/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /usr/local/share/ruby19/site_ruby/rubygems/core_ext/kernel_require.rb:144:in `require'
from Mailer.rb:3:in `<main>'
note this error only occurs in production on AWS with Ruby 1.9.3. In development with Ruby 2, it works fine.
Sorry, this is no solution, only an explanation why it works correct with ruby 2.0 but not with 1.9.3:
Since ruby 2.0 all scripts are utf-8-encoded (unless something else is defined)
What is Ruby 2.0.0
[...]
Language core features
[...]
The UTF-8 default encoding, which make many magic comments omissible
Source: https://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/
In Ruby 1.9 UTF-8 is not the default, so there may be a encoding difference between your script in UTF-8 and the script you call.
I solved this issue adding this to my gemfile:
gem 'oj'
gem 'oj_mimic_json'
then run bundle install and try to run server again
Related
I'm trying to use this gem: csv2json (0.3.0) and I'm getting an error.
On my file essaie.rb:
require 'csv2json'
File.open('essaie.csv', 'r') do |input|
File.open('output.json', 'w') do |output|
CSV2JSON.parse(input, output)
end
end
user#user-ThinkPad-L430:~/development/public/opendata/other$ ruby essaie.rb
/home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- orderedhash (LoadError)
from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.3.0/lib/csv2json.rb:4:in `<top (required)>'
from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from essaie.rb:1:in `<main>'
When I remove the version 0.3.0(csv2json) and I installed the previous version I'm getting this error:
user#user-ThinkPad-L430:~/development/public/opendata/other$ ruby essaie.rb
/home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `initialize': wrong number of arguments (2 for 0) (ArgumentError)
from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `new'
from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `parse'
from essaie.rb:5:in `block (2 levels) in <main>'
from essaie.rb:4:in `open'
from essaie.rb:4:in `block in <main>'
from essaie.rb:3:in `open'
from essaie.rb:3:in `<main>'
any help?
notes : file name essaie.csv contains the same data as input.csv (from the example of the documentation)
Just ran into this myself. Looks like they just forgot a dependency. Gems come with a list of other gems they require, but this developer probably had the orderedhash gem installed already and didn't pay attention to the need for it to be part of the dependency list for csv2json.
I typed:
gem install orderedhash
And then csv2json worked just fine for me.
See also a github issue recently opened about this:
https://github.com/darwin/csv2json/issues/12
I have installed ruby 2.1.1 using rvm after root login. In another user login ruby 1.8.7 is in use. with 1.8.7 Redmine 2.5.0 works fine. but with 2.1.0
command:
ruby script/rails server webrick -d -e production
error:
/usr/local/rvm/gems/ruby-2.1.1/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:252:in `require': /usr/local/rvm/gems/ruby-2.1.1/gems/vpim-0.695/lib/vpim/vcard.rb:679: invalid multibyte escape: /^\xFE\xFF/ (SyntaxError)
invalid multibyte escape: /^\xFF\xFE/
from /usr/local/rvm/gems/ruby-2.1.1/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:252:in `block in require'
from /usr/local/rvm/gems/ruby-2.1.1/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:237:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.1.1/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:252:in `require'
from /usr/local/rvm/gems/ruby-2.1.1/gems/vpim-0.695/lib/vpim.rb:12:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
from /home/dax/redmine-2.5.0/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-3.2.17/lib/rails/commands.rb:53:in `require'
from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-3.2.17/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-3.2.17/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-3.2.17/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Try to remove the gem vpim with this command:
gem uninstall vpim
I've tried an installation and don't need this gem.
If you really need that gem edit the file
/usr/local/rvm/gems/ruby-2.1.1/gems/vpim-0.695/lib/vpim/vcard.rb
and place this in the first line:
# encoding: US-ASCII
The vpim gem mentioned in your stack trace is not a requirement of core Redmine. It seems you have a custom plugin which requires that gem and which is not compatible with newer Ruby versions (i.e. anything >= 1.9).
To solve this issue, you thus need to update or remove that custom plugin. Also, right now, it is probably a good idea to not use Ruby 2.1 but Ruby 2.0 as it seems that Redmine core (or more generally, Rails 3.2) still has other issues with Ruby 2.1.1.
Because of a bug with Float#round in Ruby 1.8.6, I was forced to upgrade to 1.9.3 and boy was that awful. After install, irb didn't work, complaining of a lack of psych. So I tried to install the gem, but it was angry that libyaml didn't exist, so I installed that. Not sure why they weren't included if they were so important.
Now when I use require 'Location.rb' (after having to specify that I actually do want to look in the current folder... using $LOAD_PATH), I get this error:
LoadError: cannot load such file -- crack/xml
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/ap-0.1.1/lib/ap.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/tyre77/Dropbox/Aurora/GMap.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'
What does this mean? Also, when I execute ruby -v, it lists my version as 1.9.3p0 but this is dicking around in 1.9.1? All I want is my irb back and working!
It turned out that Ruby was looking for an XML parser called 'crack'. I don't know why it is referencing 2 versions of Ruby or why these dependencies aren't included in the Ruby build (since irb won't work without them) but to fix I installed the crack gem. sudo gem install crack
you can use
require_relative 'Location.rb'
or
require './Location.rb'
I have both ruby 1.8.7 and 1.9.2 installed on my system. I have a rails project that I initially built with ruby 1.9.2; but because I heare 1.8.7 is faster, I am trying to switch and finish it using ruby 1.8.7. However, whenever I run certain commands, right now its Rails g, I get the following output in my terminal:
C:\Users\Edu\workspace\tasks>rails g
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/depende
ncies.rb:234:in `load': C:/Users/Edu/workspace/tasks/config/initializers/session
_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_tasks_session'
^
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_su
pport/dependencies.rb:234:in `load'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_su
pport/dependencies.rb:223:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_su
pport/dependencies.rb:640:in `new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_su
pport/dependencies.rb:223:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_su
pport/dependencies.rb:234:in `load'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.r
b:556
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.r
b:555:in `each'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.r
b:555
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initiali
zable.rb:30:in `instance_exec'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initiali
zable.rb:30:in `run'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initiali
zable.rb:55:in `run_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initiali
zable.rb:54:in `each'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initiali
zable.rb:54:in `run_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/applicat
ion.rb:96:in `initialize!'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/
configurable.rb:30:in `send'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/
configurable.rb:30:in `method_missing'
from C:/Users/Edu/workspace/tasks/config/environment.rb:5
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/applicat
ion.rb:83:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/applicat
ion.rb:83:in `require_environment!'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands
.rb:22
from script/rails:6:in `require'
from script/rails:6
From reading other problems, it has to do with 1.8 not understanding some of the syntax of rails 3.1. My question is, are there any resources for getting this resolved? I really like to added speed of 1.8.7 in my development and testing of apps. if not, are there any other suggestions to speed up my development?
You (or someone else) has generated the application using Ruby 1.9. This means that it is using the new-to-1.9 variant of hashes (key: value) rather than the 1.8 version (:key => value).
You will need to update this to be the latter inside config/initializers/session_store.rb if you want to use this application on 1.8.7.
I am trying to run the wsdl2ruby.rb script that comes with the soap4r gem, and get the following errors:
[ral#lap etc]$ ruby /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/charset.rb:13: warning: variable $KCODE is no longer effective
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:68: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:69: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:70: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/xmlparser.rb:74:in `<top (required)>': XML processor module not found. (RuntimeError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/parser.rb:13:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:11:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:9:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:11:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:5:in `<main>'
I have the following gems installed:
httpclient (2.2.0.1) minitest (1.6.0)
rake (0.8.7) rdoc (2.5.8) soap4r
(1.5.8)
I have tried to install the xml parser gem which fails with loads of errors: http://pastie.org/1822127
Does anyone know what the problem is? This is my first time touching Ruby.
Is soap4r the best tool for the job for making a SOAP webservice client?
Thanks a lot!
The answer posted at
http://railsforum.com/viewtopic.php?id=41231
worked for me. That is, I edited the file rubyhome/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/xmlparser.rb and changed line 66 from:
c.downcase == name
to
c.to_s.downcase == name
and the problem appears to be solved.
You might also try the new official repo on Github that has this fix, and others applied to the master branch. You'll need to set your Gemfile to use the git repo as such:
gem 'soap4r', :git => 'git://github.com/felipec/soap4r.git'