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

pygments_ext not found #7

Closed
serialhex opened this issue Sep 12, 2011 · 16 comments
Closed

pygments_ext not found #7

serialhex opened this issue Sep 12, 2011 · 16 comments

Comments

@serialhex
Copy link

hi, when i try to run bench.rb i get this:

serialhex@mobilhex [~/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1]$ ruby bench.rb                                                                          [ruby-1.9.2-p290] 
/home/serialhex/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- pygments_ext (LoadError)
        from /home/serialhex/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/c.rb:7:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/c.rb:45:in `highlight'
        from bench.rb:14:in `<main>'

i manually looked for the file and there is none. from what i understand this uses embedded python, so i shouldn't need python installed (though it is). just so you know, i'm running archlinux & rvm with ruby 1.9.2 if you need any other information let me know
hex

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

The C extension is not included with the gem. You can only use the FFI interface.

@serialhex
Copy link
Author

hmm, ok, well commenting out Pygments::C.highlight(code, :lexer => 'ruby'), in bench.rb gives me this:

serialhex@mobilhex [~/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1]$ ruby bench.rb                                                                          [ruby-1.9.2-p290] 
  File "<string>", line 1
    import sys; print sys.executable
                        ^
SyntaxError: invalid syntax
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
/home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:75:in `block in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError)
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `map'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `ffi_lib'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:29:in `<module:Python>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:21:in `<top (required)>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `load'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `reload_library'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:104:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:8:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:81:in `highlight'
        from bench.rb:15:in `<main>'

yes, a fun set of debugging this is going to be :P any ideas?
hex

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

Weird. Can you try using the library instead of running the benchmark? Either bundle install && rake to run the tests, or simply ruby -e' require "pygments"; puts Pygments.highlight("1+2", :lexer => "ruby")'

@serialhex
Copy link
Author

same thing:

serialhex@mobilhex [~]$ ruby -e 'require "pygments"; puts Pygments.highlight("1+2", :lexer => "ruby")'                                                          [ruby-1.9.2-p290] 
  File "<string>", line 1
    import sys; print sys.executable
                        ^
SyntaxError: invalid syntax
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
/home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:75:in `block in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError)
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `map'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `ffi_lib'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:29:in `<module:Python>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:21:in `<top (required)>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `load'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `reload_library'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:104:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:8:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:81:in `highlight'
        from -e:1:in `<main>'

i was trying to get octopress syntax highlighting working & i boiled it down to this... :-/ i'm not sure what the deal is

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

What linux distro is this on?

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

Sounds like this line is failing: https://github.com/halostatue/rubypython/blob/master/lib/rubypython/pythonexec.rb#L16

Can you try doing that via irb or similar? %x(python -c "print 123")

@serialhex
Copy link
Author

32bit archlinux... and i keep it pretty up to date also. i take it there is probably some fun library that might have broken backwards-compatibility on the near-bleeding-edge of things? ahh the joys of being fully up-to-date :P

@serialhex
Copy link
Author

ahh, i think i see:

justin@act-linux [~/src/tmp]$ pry                                                                                                                                                                                                                           [ruby-1.9.2-p290] 
pry(main)> %x(python -c "print 123")
  File "<string>", line 1
    print 123
            ^
SyntaxError: invalid syntax
=> ""
pry(main)> %x(python2 -c "print 123")
=> "123\n"

python 2.x is named python2 in archlinux... python is python 3.x ... so maybe get the version string & if it's not <3 then try python2 (i think it's named that on gentoo systems too) and see if that works...?

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

require 'pygments'
RubyPython.configure :python_exe => 'python2'
puts Pygments.highlight(File.read(__FILE__), :lexer => 'ruby')

@serialhex
Copy link
Author

hmm... sticking that into a file and running it gives me:

serialhex@arch-hex [~/tmp]$ ruby tmp.rb
/home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:75:in `block in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError)
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `map'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.9/lib/ffi/library.rb:54:in `ffi_lib'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:29:in `<module:Python>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython/python.rb:21:in `<top (required)>'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `load'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:261:in `reload_library'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.1/lib/rubypython.rb:104:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:8:in `start'
        from /home/serialhex/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.2.1/lib/pygments/ffi.rb:81:in `highlight'
        from tmp.rb:3:in `<main>'

so that's not it :(

@tmm1
Copy link
Contributor

tmm1 commented Sep 12, 2011

Where is libpython2 on your system? Check ldd $(which python2)

@serialhex
Copy link
Author

serialhex@mobilhex [~]$ ldd $(which python2)                                                                                                                    [ruby-1.9.2-p290] 
        linux-gate.so.1 =>  (0xb787a000)
        libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0xb76c5000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb76aa000)
        libc.so.6 => /lib/libc.so.6 (0xb7543000)
        libdl.so.2 => /lib/libdl.so.2 (0xb753e000)
        libutil.so.1 => /lib/libutil.so.1 (0xb7539000)
        libm.so.6 => /lib/libm.so.6 (0xb750f000)
        /lib/ld-linux.so.2 (0xb787b000)

@ngty
Copy link

ngty commented Sep 21, 2011

I'm a arch user as well, I've managed to fix my problem by doing:

RubyPython.configure :python_exe => 'python2.7'

Hope this helps :]

@Gonzih
Copy link

Gonzih commented Sep 21, 2011

@ngty Thanks man! It's works now!

@serialhex
Copy link
Author

@ngty i just tried this, and it works beautifully!!! thank you!

@nkoehring
Copy link

Strange, I'm sticking to the same problem as @serialhex before and now I'm stuck. Like before I got the issue with finding the correct python exe. After fixing it I still get the missing lib.so error.

I test this with

ruby -e' require "pygments"; RubyPython.configure :python_exe => "python2.7"; puts Pygments.highlight("1+2", :lexer => "ruby")'

UPDATE

I found out that the missing lib.so thing comes due a nil in the list of libraries to load. It happens in /ffi-1.0.11/lib/ffi/library.rb so it seems to be an problem of the FFI gem.

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

5 participants