GithubHelp home page GithubHelp logo

pygments_ext not found about pygments.rb HOT 16 CLOSED

serialhex avatar serialhex commented on September 21, 2024
pygments_ext not found

from pygments.rb.

Comments (16)

tmm1 avatar tmm1 commented on September 21, 2024

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

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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

from pygments.rb.

tmm1 avatar tmm1 commented on September 21, 2024

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")'

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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

from pygments.rb.

tmm1 avatar tmm1 commented on September 21, 2024

What linux distro is this on?

from pygments.rb.

tmm1 avatar tmm1 commented on September 21, 2024

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")

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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...?

from pygments.rb.

tmm1 avatar tmm1 commented on September 21, 2024
require 'pygments'
RubyPython.configure :python_exe => 'python2'
puts Pygments.highlight(File.read(__FILE__), :lexer => 'ruby')

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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 :(

from pygments.rb.

tmm1 avatar tmm1 commented on September 21, 2024

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

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024
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)

from pygments.rb.

ngty avatar ngty commented on September 21, 2024

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 :]

from pygments.rb.

Gonzih avatar Gonzih commented on September 21, 2024

@ngty Thanks man! It's works now!

from pygments.rb.

serialhex avatar serialhex commented on September 21, 2024

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

from pygments.rb.

nkoehring avatar nkoehring commented on September 21, 2024

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.

from pygments.rb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.