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

Failed to allocate instance of opencc #2

Closed
UlyssesZh opened this issue Jan 4, 2024 · 3 comments
Closed

Failed to allocate instance of opencc #2

UlyssesZh opened this issue Jan 4, 2024 · 3 comments

Comments

@UlyssesZh
Copy link

require 'opencc'
OpenCC.t2s '測試'
/home/ulysses/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/opencc-rb-1.0.6/lib/opencc.rb:25:in `initialize': (opencc_open) failed to allocate instance of opencc (Exception)
	from /home/ulysses/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/opencc-rb-1.0.6/lib/opencc.rb:25:in `new'
	from /home/ulysses/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/opencc-rb-1.0.6/lib/opencc.rb:25:in `block (2 levels) in singleton class'
	from (irb):2:in `<main>'
	from /home/ulysses/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.11.0/exe/irb:9:in `<top (required)>'
	from /home/ulysses/.local/share/rtx/installs/ruby/3.2.2/bin/irb:25:in `load'
	from /home/ulysses/.local/share/rtx/installs/ruby/3.2.2/bin/irb:25:in `<main>'
  • Ruby 3.2.2
  • opencc-rb 1.0.6
  • OpenCC 1.1.1
@songjiz
Copy link
Owner

songjiz commented Mar 21, 2024

I apologize for the delay in my response. Based on your description, I tested locally with Ruby 3.2.2 and 3.3.0, and everything worked fine. Could you provide more details?

Here are some possible steps to troubleshoot:

  1. Operating System: Confirm which operating system you are using (e.g., Windows, macOS, or Linux).
  2. Ruby Version Manager: You mentioned Ruby 3.2.2, but make sure you’re using a Ruby version manager (e.g., RVM, rbenv, or asdf).

Thanks!

@songjiz
Copy link
Owner

songjiz commented Mar 21, 2024

I used the mise(formerly known as rtx) as version manager, and everything worked fine.

  • step 1

    mise current

    output

    ruby 3.2.2
    
  • step 2

    which gem

    output

    .local/share/mise/installs/ruby/3.2.2/bin/gem
    
    which irb

    output

    .local/share/mise/installs/ruby/3.2.2/bin/irb
    
  • step 3

    gem install opencc-rb

    output

    Building native extensions. This could take a while...
    Successfully installed opencc-rb-1.0.6
    Parsing documentation for opencc-rb-1.0.6
    Installing ri documentation for opencc-rb-1.0.6
    Done installing documentation for opencc-rb after 0 seconds
    1 gem installed
    
  • step 4

    irb
    irb(main):001:0> require 'opencc'
    irb(main):002:0> OpenCC.t2s '測試'
    => "测试"

@UlyssesZh
Copy link
Author

I originally got this error on Ubuntu. Now I already deleted that OS.

I tried just now with Arch Linux and NixOS, but I cannot reproduce the bug now. I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants