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

Encoding is not available to Ruby scripts on 1.2 #433

Closed
jferris opened this Issue Jun 3, 2015 · 18 comments

Comments

Projects
None yet
9 participants
@jferris
Copy link

commented Jun 3, 2015

You can reproduce this with the following Ruby script:

require "uri"

I get the following error:

   weechat =!= | ruby: error: eval:31:in `module_eval': uninitialized
               | constant Encoding::UTF_7 (NameError)
   weechat =!= | ruby: error:      from
               | /usr/lib/ruby/2.2.0/uri/common.rb:15:in `<top (required)>'
   weechat =!= | ruby: error:      from /usr/lib/ruby/2.2.0/rubygems/core_e
               | xt/kernel_require.rb:54:in `require'
   weechat =!= | ruby: error:      from /usr/lib/ruby/2.2.0/rubygems/core_e
               | xt/kernel_require.rb:54:in `require'
   weechat =!= | ruby: error:      from /usr/lib/ruby/2.2.0/uri.rb:104:in
               | `<top (required)>'
   weechat =!= | ruby: error:      from /usr/lib/ruby/2.2.0/rubygems/core_e
               | xt/kernel_require.rb:54:in `require'
   weechat =!= | ruby: error:      from /usr/lib/ruby/2.2.0/rubygems/core_e
               | xt/kernel_require.rb:54:in `require'
   weechat =!= | ruby: error:      from (eval):33:in `load_eval_file'
   weechat =!= | ruby: error:      from eval:31:in `module_eval'
   weechat =!= | ruby: error:      from eval:31:in `load_eval_file'

I'm on Ruby 2.2.2, Weechat 1.2, Arch Linux:

% ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
/v
WeeChat 1.2 [compiled on May 12 2015 19:42:29]
% uname -a
Linux brixie 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:05:23 UTC 2015 x86_64 GNU/Linux

@flashcode flashcode added the bug label Jun 4, 2015

@evilgawd

This comment has been minimized.

Copy link

commented Jun 15, 2015

Same issue on Fedora 22

ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
/v
WeeChat 1.2 [compiled on May 22 2015 09:58:59]
uname -a
Linux 4.0.4-303.fc22.x86_64 #1 SMP Thu May 28 12:37:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

weechat =!= | ruby: error while loading file "/home/blip/.weechat/ruby/autoload/pushover-weechat.rb"
weechat =!= | ruby: error: eval:31:in module_eval': uninitialized constant Encoding::UTF_7 (NameError) weechat =!= | ruby: error: from /usr/share/ruby/uri/common.rb:15:in<top (required)>'
weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:inrequire'
weechat =!= | ruby: error: from /usr/share/ruby/uri.rb:104:in <top (required)>' weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:inrequire'
weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' weechat =!= | ruby: error: from /usr/share/ruby/net/http.rb:23:in<top (required)>'
weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:inrequire'
weechat =!= | ruby: error: from /usr/share/ruby/net/https.rb:21:in <top (required)>' weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:inrequire'
weechat =!= | ruby: error: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' weechat =!= | ruby: error: from (eval):78:inload_eval_file'
weechat =!= | ruby: error: from eval:31:in module_eval' weechat =!= | ruby: error: from eval:31:inload_eval_file'

@evilgawd

This comment has been minimized.

Copy link

commented Jun 23, 2015

Is there any workaround for this ?

@flashcode

This comment has been minimized.

Copy link
Member

commented Jun 23, 2015

For now I have no workaround.
I'll have to dig this problem, but I'm not an expert with Ruby so any help is appreciated to fix this problem.

@akaritakai

This comment has been minimized.

Copy link

commented Jul 14, 2015

I also ran into this on 1.3 while using a gem that required uri. I don't have a workaround either.

@ChinnoDog

This comment has been minimized.

Copy link

commented Jul 14, 2015

I found this problem in 1.3 after doing a package upgrade on my Ubuntu server. I use slacklog.rb and encounter this error when I attempt to load it in weechat. I used irb to interactively load the script's object and it does not complain. The uri issue only appears in weechat. I only have one version of Ruby on my server and that is 2.0.

@flashcode

This comment has been minimized.

Copy link
Member

commented Jul 16, 2015

Ruby developers/gurus: a patch is still welcome for this issue :)

@akerl

This comment has been minimized.

Copy link

commented Sep 5, 2015

So the encodings made available inside weechat differ dramatically from those on the system:

irb(main):001:0> Encoding.list.join(',')
=> "ASCII-8BIT,UTF-8,US-ASCII,UTF-16BE,UTF-16LE,UTF-32BE,UTF-32LE,UTF-16,UTF-32,UTF8-MAC,EUC-JP,Windows-31J,Big5,Big5-HKSCS,Big5-UAO,CP949,Emacs-Mule,EUC-KR,EUC-TW,GB2312,GB18030,GBK,ISO-8859-1,ISO-8859-2,ISO-8859-3,ISO-8859-4,ISO-8859-5,ISO-8859-6,ISO-8859-7,ISO-8859-8,ISO-8859-9,ISO-8859-10,ISO-8859-11,ISO-8859-13,ISO-8859-14,ISO-8859-15,ISO-8859-16,KOI8-R,KOI8-U,Shift_JIS,Windows-1251,IBM437,IBM737,IBM775,CP850,IBM852,CP852,IBM855,CP855,IBM857,IBM860,IBM861,IBM862,IBM863,IBM864,IBM865,IBM866,IBM869,Windows-1258,GB1988,macCentEuro,macCroatian,macCyrillic,macGreek,macIceland,macRoman,macRomania,macThai,macTurkish,macUkraine,CP950,CP951,stateless-ISO-2022-JP,eucJP-ms,CP51932,EUC-JIS-2004,GB12345,ISO-2022-JP,ISO-2022-JP-2,CP50220,CP50221,Windows-1252,Windows-1250,Windows-1256,Windows-1253,Windows-1255,Windows-1254,TIS-620,Windows-874,Windows-1257,MacJapanese,UTF-7,UTF8-DoCoMo,SJIS-DoCoMo,UTF8-KDDI,SJIS-KDDI,ISO-2022-JP-KDDI,stateless-ISO-2022-JP-KDDI,UTF8-SoftBank,SJIS-SoftBank"
23:07:04     ruby: loading script "/home/akerl/.weechat/ruby/autoload/dummy.rb"
23:07:04     ASCII-8BIT,UTF-8,US-ASCII,UTF-16BE,UTF-16LE,UTF-32BE,UTF-32LE,UTF-16,UTF-32,UTF8-MAC,EUC-JP,Windows-31J

That script uses the following the generate that output:

Weechat.print '', Encoding.list.join(',')

Was there a code change recently that would have impacted the locales you present when loading Ruby?

@akerl

This comment has been minimized.

Copy link

commented Sep 5, 2015

@akerl

This comment has been minimized.

Copy link

commented Sep 5, 2015

My C skills are pretty horrible, but looking at d8b9e0a, it looks like you may be checking defined(RUBY_API_VERSION_MAJOR) before #include <ruby/version.h>, which is the header that defines RUBY_API_VERSION_MAJOR. Based on that, it looks like #include <ruby/encoding.h> would never be utilized

@akerl

This comment has been minimized.

Copy link

commented Sep 5, 2015

No luck. Removing that had no visible impact

@akerl

This comment has been minimized.

Copy link

commented Sep 14, 2015

@flashcode Have you had a chance to look into this? It's pretty crippling given that ever since upgrading to latest weechat, ruby scripts are all dead in the water

@flashcode

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

@akerl: I played with the include of encoding.h, but no luck, I think the problem is not there.

The problem could be in weechat_ruby_code (in function weechat_plugin_init), the code used to load and eval scripts.
But I don't know what is wrong, so any help is still welcome for this issue.

@jkolo

This comment has been minimized.

Copy link

commented Oct 4, 2015

For me workaround/solution is to add to script (.weechat/ruby/<name_of_script>.rb) line require 'enc/encdb.so' as the first require

@gsingh93

This comment has been minimized.

Copy link

commented Oct 25, 2015

@jkolo's workaround works for me. Hopefully this gets a proper solution sometime soon.

@flashcode

This comment has been minimized.

Copy link
Member

commented Oct 26, 2015

Yes it works with this workaround, but I'm not able to apply this workaround on the script loader (in weechat-ruby.c).
The enc/encdb.so should already be included.

@flashcode

This comment has been minimized.

Copy link
Member

commented Oct 26, 2015

Ah, good news, just found a way to fix the problem by moving the include of enc/encdb.so just before evaluating the script code (before module_eval(lines)).
I'll make some tests and commit if it's OK.

@flashcode flashcode closed this in 4f867a8 Oct 27, 2015

@flashcode flashcode removed the help wanted label Oct 27, 2015

@flashcode flashcode added this to the 1.4 milestone Oct 27, 2015

@flashcode flashcode self-assigned this Oct 27, 2015

@flashcode

This comment has been minimized.

Copy link
Member

commented Oct 27, 2015

Please try with the latest commit, it should fix the problem.

@The-Compiler

This comment has been minimized.

Copy link

commented Dec 8, 2015

Gosh, I didn't update in ages... on the bright side, I can confirm the fix works 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.