Comments (16)
The C extension is not included with the gem. You can only use the FFI interface.
from pygments.rb.
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.
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.
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.
What linux distro is this on?
from pygments.rb.
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.
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.
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.
require 'pygments'
RubyPython.configure :python_exe => 'python2'
puts Pygments.highlight(File.read(__FILE__), :lexer => 'ruby')
from pygments.rb.
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.
Where is libpython2
on your system? Check ldd $(which python2)
from pygments.rb.
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.
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.
@ngty Thanks man! It's works now!
from pygments.rb.
@ngty i just tried this, and it works beautifully!!! thank you!
from pygments.rb.
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)
- Broken symlink in gem (find_error.py) HOT 8
- github.py is included in pygments-main HOT 2
- Possibility to add a custom lexer HOT 8
- Liquid Exception in markdown format HOT 1
- Reanimate JRuby CI
- Raku support HOT 1
- support pygments >= 2.7.1 HOT 1
- Becoming a maintainer HOT 6
- Set up Rubocop lint checking in CI
- Race condition between watchdog/main thread leads to "Thread killed" on JRuby
- Old-fashioned questions
- Add an API to query underlying Pygments version
- undefined method 'create' HOT 4
- Tests break against python3-pygments (=2.10.0+dfsg-1) HOT 2
- env: python: No such file or directory HOT 2
- Broken pipe error in Mentos HOT 22
- Update pygments to 2.14.0
- Virtual environment Pythons are ignored on Windows
- `guess()` from Ruby HOT 1
- Update Pygments HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygments.rb.