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

Lib.so issues when calling Pygments::Lexer #10

Closed
yholkamp opened this issue Oct 22, 2011 · 48 comments
Closed

Lib.so issues when calling Pygments::Lexer #10

yholkamp opened this issue Oct 22, 2011 · 48 comments

Comments

@yholkamp
Copy link

When running the Pyagments::Lexer class (as shown below) it complains about the lib.so file not being found. As the issue seemed similar to issue #7 I've tried following the steps there but this did not resolve the issue, the output below also contains an attempt at using the RubyPython configuration but neither the options 'python' nor 'python2' seem to help (which makes sense as python is available under the 'python' alias rather than python2).
The path suggested for 64-bit RHEL as suggested on http://www.dejaaugustine.com/2011/10/rubypython-on-64-bit-rhel5centos/ did not resolve this issue either.

 => {:python_exe=>"python"} 
ruby-1.9.2-p290 :002 > Pygments::Lexer[:bash]
LoadError: Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:121:in`block in ffi_lib'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:88:in `map'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:88:in`ffi_lib'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython/python.rb:29:in `<module:Python>'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython/python.rb:21:in`<top (required)>'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in`block in load'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in`new_constants_in'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in`load'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython.rb:261:in `reload_library'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython.rb:104:in`start'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/ffi.rb:8:in `start'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/ffi.rb:42:in`lexers'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/lexer.rb:147:in `<module:Pygments>'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/lexer.rb:1:in`<top (required)>'
        from (irb):2
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in`start'
        from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in`require'
        from script/rails:6:in `<main>'

This is on a machine with Debian 6 x64 with ia32 libs installed, Python 2.6.6 and Ruby 1.9.2. I suppose this should just be able to run or am I overlooking another requirement? Thanks in advance either way.

@tmm1
Copy link
Contributor

tmm1 commented Oct 22, 2011

Try :exe => 'python2.6'

On Sat, Oct 22, 2011 at 2:25 PM, Yorick <
reply@reply.github.com>wrote:

When running the Pyagments::Lexer class (as shown below) it complains about
the lib.so file not being found. As the issue seemed similar to #7 I've
tried following the steps there but this did not resolve the issue, the
output below also contains an attempt at using the RubyPython configuration
but neither the options 'python' nor 'python2' seem to help (which makes
sense as python is available under the 'python' alias rather than python2).

 => {:python_exe=>"python"}
ruby-1.9.2-p290 :002 > Pygments::Lexer[:bash]
LoadError: Could not open library 'lib.so': lib.so: cannot open shared
object file: No such file or directory
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:121:in
`block in ffi_lib'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:88:in
`map'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/ffi-1.0.10/lib/ffi/library.rb:88:in
`ffi_lib'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython/python.rb:29:in
`<module:Python>'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython/python.rb:21:in
`<top (required)>'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in
`load'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in
`block in load'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in
`block in load_dependency'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in
`new_constants_in'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in
`load_dependency'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in
`load'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython.rb:261:in
`reload_library'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/rubypython-0.5.2/lib/rubypython.rb:104:in
`start'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/ffi.rb:8:in
`start'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/ffi.rb:42:in
`lexers'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/lexer.rb:147:in
`<module:Pygments>'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/pygments.rb-0.2.3/lib/pygments/lexer.rb:1:in
`<top (required)>'
       from (irb):2
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in
`start'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in
`start'
       from /home/ruby/.rvm/gems/ruby-1.9.2-p290@gitlab/gems/railties-3.1.0/lib/rails/commands.rb:40:in
`<top (required)>'
       from script/rails:6:in`require'
       from script/rails:6:in `<main>'

This is on a machine with Debian 6 x64 with ia32 libs installed, Python
2.6.6 and Ruby 1.9.2. I suppose this should just be able to run or am I
overlooking another requirement? Thanks in advance either way.

--
Reply to this email directly or view it on GitHub:
#10

@yholkamp yholkamp reopened this Oct 22, 2011
@tmm1
Copy link
Contributor

tmm1 commented Oct 22, 2011

This must be an issue with the .so lookup code /cc @halostatue

Can you make sure you have a python-dev package installed?

@yholkamp
Copy link
Author

After running a apt-get install python-dev it works flawlessly - I didn't realize this was a requirement for the gem, thanks a lot!

@tmm1
Copy link
Contributor

tmm1 commented Oct 23, 2011

Can you check what ls -alh /usr/lib/libpython2.*.so returns?

The python-dev package adds a .so symlink to an existing libpython.so.1 usually, which rubypython also looks for. What is the full filename for libpython on your machine?

@halostatue
Copy link

wouldn't it be ls -alh /usr/lib/libpython2_so_ (no dots) to get the best information?

@yholkamp
Copy link
Author

Running that command even more generic gives the following output;

$ ls -alh /usr/lib/libpython*so*
lrwxrwxrwx 1 root root   17 Oct 23 01:02 /usr/lib/libpython2.6.so -> libpython2.6.so.1
lrwxrwxrwx 1 root root   19 Oct 23 01:02 /usr/lib/libpython2.6.so.1 -> libpython2.6.so.1.0
-rw-r--r-- 1 root root 2.7M Dec 27  2010 /usr/lib/libpython2.6.so.1.0

@halostatue
Copy link

Interesting. I'm guessing that if you removed python-dev (actually python2.6-dev), both symlinks (libpython2.6.so and libpython2.6.so.1) would be removed. I can add another special case for .so.1.0 so that python-dev isn't necessary, but that seems a little ugly.

@halostatue
Copy link

OK, so that guess was wrong. However, we should be looking for libpython2.6.so.1 anyway, per pythonexec.rb line 61. I'm confused, now.

@tmm1
Copy link
Contributor

tmm1 commented Oct 23, 2011

Can you try something like: for i in /usr/lib/libpython*so*; do dpkg -S $i; done

@sairam
Copy link

sairam commented Oct 23, 2011

If you are looking for the solution for a Fedora x64 distro, Here is the solution:

install python-devel via yum . it would point the libpython*so* at /usr/lib64/ . But the ffi only looks at /usr/lib/ .

yum install python-devel
cd /usr/lib
ln -sf /usr/lib64/libpython2.6.so
ln -sf /usr/lib64/libpython2.6.so.1.0

@halostatue
Copy link

@sairam: that's no longer necessary as of rubypython 0.5.3.

The problem is that for some reason, libpython2.6.so.1 isn't being seen and it should be.

@sairam
Copy link

sairam commented Oct 24, 2011

looks like rubypython 0.5.3 was released just yesterday. tried upgrading to 0.5.3 . my gemfile locked it to 0.5.1 and hence the problem . Thanks @halostatue

@yholkamp
Copy link
Author

@tmm1:```
python2.6-dev: /usr/lib/libpython2.6.so
libpython2.6: /usr/lib/libpython2.6.so.1
libpython2.6: /usr/lib/libpython2.6.so.1.0

@lmarburger
Copy link

I'm having the same issue running on Heroku's cedar stack since upgrading to the latest version fo pygments.rb and rubypython. Here's the output from the command @tmm1 pasted:

irb(main):015:0> puts `for i in /usr/lib/libpython*so*; do dpkg -S $i; done`
puts `for i in /usr/lib/libpython*so*; do dpkg -S $i; done`
libpython2.6: /usr/lib/libpython2.6.so.1
libpython2.6: /usr/lib/libpython2.6.so.1.0

Things seem to be fine rolling back to rubypython 0.5.1 and pygments.rb 0.2.3.

@halostatue
Copy link

@lmarburger, I'm not familiar with Heroku, so can you grab the latest rubypython from git (I'm working on 0.6) and give me the output of the following?

require 'rubypython'
p RubyPython::Instance.new({}).library

I'm trying to figure out why things are failing; it worked just fine for me on Ubuntu 11.04 after I installed libpython.

@lmarburger
Copy link

No problem, @halostatue. I grabbed HEAD from https://github.com/halostatue/rubypython and I get NameError: uninitialized constant RubyPython::Instance.

For the record, I think something's broken with python2.7 on their stack. I have an open support ticket, but they haven't repsonded.

irb(main):001:0> require 'rubypython' 
=> true 
irb(main):002:0> RubyPython.start 
LoadError: Could not open library '/usr/local/lib/libpython2.7.a': /usr/local/lib/libpython2.7.a: invalid ELF header

I just use python2.6 in production and everything seems to be fine.

@halostatue
Copy link

Please forgive me for being an idiot. It's RubyPython::Interpreter, not
Instance.

I am not surprised that the '.a' is failing.

-a

On Sat, Nov 26, 2011 at 8:21 PM, Larry Marburger <
reply@reply.github.com

wrote:

No problem, @halostatue. I grabbed HEAD from
https://github.com/halostatue/rubypython and I get NameError: uninitialized constant RubyPython::Instance.

For the record, I think something's broken with python2.7 on their stack.
I have an open support ticket, but they haven't repsonded.

irb(main):001:0> require 'rubypython'
=> true
irb(main):002:0> RubyPython.start
LoadError: Could not open library '/usr/local/lib/libpython2.7.a':
/usr/local/lib/libpython2.7.a: invalid ELF header

I just use python2.6 in production and everything seems to be fine.


Reply to this email directly or view it on GitHub:
#10 (comment)

Austin Ziegler austin@zieglers.ca austin@halostatue.ca
http://www.halostatue.ca/ http://twitter.com/halostatue

@lmarburger
Copy link

That explains it. I figured it was just a typo. Here's the output:

> require 'rubypython'
=> true
> RubyPython::Interpreter.new({}).library
=> "/usr/local/lib/libpython2.7.a"
> RubyPython::Interpreter.new({:python_exe => 'python2.6'}).library
=> nil

@ghost
Copy link

ghost commented Dec 30, 2011

I encountered similar issue under Archlinux X86-64. Archlinux does not have a lib64. It has /usr/lib and /usr/lib32...Also, The default python interpreter is python3, so I added RubyPython.configure :python_exe => 'python2.7' in pygments_code.rb.

I have tried both ruby-1.9.2-head and ruby-1.9.3-head, both produced look-alike error message.

My _config.yml

# ----------------------- #
#      Main Configs       #
# ----------------------- #

url: http://capsensitive.github.com
title: Titile
subtitle: A blogging framework for hackers.
author: Author
simple_search: http://google.com/search
description:

# Default date format is "ordinal" (resulting in "July 22nd 2007")
# You can customize the format as defined in
# http://www.ruby-doc.org/core-1.9.2/Time.html#method-i-strftime
# Additionally, %o will give you the ordinal representation of the day
date_format: "ordinal"

# RSS / Email (optional) subscription links (change if using something like Feedburner)
subscribe_rss: /atom.xml
subscribe_email:
# RSS feeds can list your email address if you like
email:

# ----------------------- #
#    Jekyll & Plugins     #
# ----------------------- #

# If publishing to a subdirectory as in http://site.com/project set 'root: /project'
root: /
permalink: /blog/:year/:month/:day/:title/
source: source
destination: public
plugins: plugins
code_dir: downloads/code
category_dir: blog/categories
markdown: rdiscount
pygments: false # default python pygments have been replaced by pygments.rb

paginate: 10          # Posts per page on the blog index
pagination_dir: blog  # Directory base for pagination URLs eg. /blog/page/2/
recent_posts: 5       # Posts in the sidebar Recent Posts section
excerpt_link: "Read on →"  # "Continue reading" link text at the bottom of excerpted articles

titlecase: true       # Converts page and post titles to tilecase

# list each of the sidebar modules you want to include, in the order you want them to appear.
# To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
default_asides: [asides/recent_posts.html, asides/github.html, asides/twitter.html, asides/delicious.html, asides/pinboard.html, asides/googleplus.html]

# Each layout uses the default asides, but they can have their own asides instead. Simply uncomment the lines below
# and add an array with the asides you want to use.
# blog_index_asides:
# post_asides:
# page_asides:

Error message in ruby-1.9.3-head

## Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from /home/user/.sync/Dropbox/src/octopress/_config.yml
Building site: source -> public
/home/user/.rvm/gems/ruby-1.9.2-head/gems/ffi-1.0.11/lib/ffi/library.rb:121: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/user/.rvm/gems/ruby-1.9.2-head/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `map'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `ffi_lib'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/rubypython-0.5.3/lib/rubypython/python.rb:29:in `'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/rubypython-0.5.3/lib/rubypython/python.rb:21:in `'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `load'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `reload_library'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/rubypython-0.5.3/lib/rubypython.rb:104:in `start'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:8:in `start'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:82:in `highlight'
        from /home/user/.sync/Dropbox/src/octopress/plugins/pygments_code.rb:27:in `pygments'
        from /home/user/.sync/Dropbox/src/octopress/plugins/pygments_code.rb:17:in `highlight'
        from /home/user/.sync/Dropbox/src/octopress/plugins/backtick_code_block.rb:37:in `block in render_code_block'
        from /home/user/.sync/Dropbox/src/octopress/plugins/backtick_code_block.rb:13:in `gsub'
        from /home/user/.sync/Dropbox/src/octopress/plugins/backtick_code_block.rb:13:in `render_code_block'
        from /home/user/.sync/Dropbox/src/octopress/plugins/octopress_filters.rb:12:in `pre_filter'
        from /home/user/.sync/Dropbox/src/octopress/plugins/octopress_filters.rb:27:in `pre_render'
        from /home/user/.sync/Dropbox/src/octopress/plugins/post_filters.rb:112:in `block in pre_render'
        from /home/user/.sync/Dropbox/src/octopress/plugins/post_filters.rb:111:in `each'
        from /home/user/.sync/Dropbox/src/octopress/plugins/post_filters.rb:111:in `pre_render'
        from /home/user/.sync/Dropbox/src/octopress/plugins/post_filters.rb:166:in `do_layout'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/lib/jekyll/post.rb:189:in `render'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/lib/jekyll/site.rb:193:in `block in render'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/lib/jekyll/site.rb:192:in `each'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/lib/jekyll/site.rb:192:in `render'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/lib/jekyll/site.rb:40:in `process'
        from /home/user/.rvm/gems/ruby-1.9.2-head/gems/jekyll-0.11.0/bin/jekyll:250:in `'
        from /home/user/.rvm/gems/ruby-1.9.2-head/bin/jekyll:19:in `load'
        from /home/user/.rvm/gems/ruby-1.9.2-head/bin/jekyll:19:in `'

gem infomation (rubypython is 0.5.3)

albino (1.3.3)
blankslate (2.1.2.4)
bundler (1.0.21 ruby)
chunky_png (1.2.5)
classifier (1.3.3)
compass (0.11.6)
directory_watcher (1.4.1)
fast-stemmer (1.0.0)
ffi (1.0.11)
fssm (0.2.7)
haml (3.1.4)
jekyll (0.11.0)
kramdown (0.13.4)
liquid (2.2.2)
maruku (0.6.0)
posix-spawn (0.3.6)
pygments.rb (0.2.4)
rack (1.4.0)
rake (0.9.2.2, 0.9.2)
rb-fsevent (0.4.3.1)
rdiscount (1.6.8)
RedCloth (4.2.9)
rubypants (0.2.0)
rubypython (0.5.3)
sass (3.1.12)
sinatra (1.2.6)
stringex (1.3.0)
syntax (1.0.0)
tilt (1.3.3)
albino (1.3.3)
blankslate (2.1.2.4)
bundler (1.0.21 ruby)
chunky_png (1.2.5)
classifier (1.3.3)
compass (0.11.6)
directory_watcher (1.4.1)
fast-stemmer (1.0.0)
ffi (1.0.11)
fssm (0.2.7)
haml (3.1.4)
jekyll (0.11.0)
kramdown (0.13.4)
liquid (2.2.2)
maruku (0.6.0)
posix-spawn (0.3.6)
pygments.rb (0.2.4)
rack (1.4.0)
rake (0.9.2.2, 0.9.2)
rb-fsevent (0.4.3.1)
rdiscount (1.6.8)
RedCloth (4.2.9)
rubypants (0.2.0)
rubypython (0.5.3)
sass (3.1.12)
sinatra (1.2.6)
stringex (1.3.0)
syntax (1.0.0)
tilt (1.3.3)

@Gonzih
Copy link

Gonzih commented Dec 30, 2011

I have same issue on archlinux x64

@halostatue
Copy link

@capsensitive & @Gonzih, can you try the results of what I asked of @lmarburger in November?

Unfortunately, I won't be able to look at this problem further until after an internet-free vacation that starts on Sunday, but if the new code in HEAD works for discovering the Python library properly, I will try to get a new version of RubyPython out ASAP after I'm done.

@Gonzih
Copy link

Gonzih commented Jan 6, 2012

I was trying to install rubypython from git using bundler and Gemfile and i got following:

rubypython at /blablabla/fake_path did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  ["lib/rubypython/options.rb", "lib/rubypython/pythonexec.rb", ".gemtest"] are not files

After that i was trying to build gem manually from source, but here also was some troubles:

rake gem
rake aborted!
Don't know how to build task 'lib/rubypython/options.rb'

With installed rubypython-0.5.3 i got following output:

1.9.3p0 :001 > require 'rubypython'
 => true 
1.9.3p0 :002 > RubyPython::Interpreter.new({}).library
NameError: uninitialized constant RubyPython::Interpreter
        from (irb):2
        from /home/gnzh/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

@ghost
Copy link

ghost commented Jan 7, 2012

I installed rubypython via rvm. Rubypython is a dependence for octopress, I use bundle update to install rubypython in octopress dir. No error message during installation.

1.9.2p290 :001 > require 'rubypython'
 => true
1.9.2p290 :002 > RubyPython::Interpreter.new({})
NameError: uninitialized constant RubyPython::Interpreter
        from (irb):2
        from /home/user/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'

@pimvullers
Copy link

Getting the same error here on Gentoo Linux (trying to run GitLab) with pygments.rb 0.2.3, rubypython 0.5.3 and python 2.7.2 / 3.1.4:

irb(main):003:0> require 'pygments.rb'
=> true
irb(main):004:0> Pygments::Lexer[:bash]
LoadError: Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory
    from /usr/local/lib64/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:121:in `block in ffi_lib'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `map'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `ffi_lib'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:29:in `<module:Python>'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:21:in `<top (required)>'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `load'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `reload_library'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:104:in `start'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:8:in `start'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:42:in `lexers'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/lexer.rb:147:in     `<module:Pygments>'
    from /usr/local/lib64/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/lexer.rb:1:in `<top (required)>'
    from (irb):4
    from /usr/bin/irb:12:in `<main>'

@rolinh
Copy link

rolinh commented Jan 12, 2012

Hi there,

I am having the same issue and output as capsensitive on Archlinux (both 64 and 32-bit). rubypython is at version 0.5.3.
Running this:

require 'rubypython'
RubyPython.configure :python_exe => 'python2.7'
p RubyPython::Interpreter.new({}).library

Returns

test.rb:3:in `<main>': uninitialized constant RubyPython::Interpreter (NameError)

Same when setting python_exe to python2.

@ghost
Copy link

ghost commented Jan 17, 2012

Hi,

I believe that this lib.so error is due to pygments.rb. I just manually locked pygments.rb to 0.1.3, and octopress can generate pages successfully. Here is the workaround:

  • Workaround:
    Lock the pygments.rb version (0.1.3) in Gemfile. Modify gem 'pygments.rb' to gem 'pygments.rb', '0.1.3. And run bundle install under your octopress working directory.

That workaround should also work under Gentoo, I think. But I have no idea why newer pygments.rb cause trouble only in Archlinux and Gentoo.

@rolinh
Copy link

rolinh commented Jan 17, 2012

Hi,

I wish I could confirm your workaround but unfortunately, I can't. It actually made things worst.

/home/robin/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/lib/ffi/library.rb:121: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/robin/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `map'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `ffi_lib'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.3/lib/rubypython/python.rb:29:in `<module:Python>'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.3/lib/rubypython/python.rb:21:in `<top (required)>'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `load'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `reload_library'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/rubypython-0.5.3/lib/rubypython.rb:104:in `start'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.1.3/lib/pygments/ffi.rb:8:in `start'
    from /home/robin/.rvm/gems/ruby-1.9.2-p290/gems/pygments.rb-0.1.3/lib/pygments/ffi.rb:82:in `highlight'
(and so on...)

Before that, I could rake generate my octopress blog on archlinux but instead of showing codeblocks, it would show the message about missing lib.so on the blog.

@Gonzih
Copy link

Gonzih commented Jan 17, 2012

I have same situation as @rolinh have.

Here list of my gems:

╰─➤  bundle show                                     1 ↵
Gems included by the bundle:
  * RedCloth (4.2.9)
  * albino (1.3.3)
  * blankslate (2.1.2.4)
  * bundler (1.1.rc)
  * chunky_png (1.2.5)
  * classifier (1.3.3)
  * compass (0.11.6)
  * directory_watcher (1.4.1)
  * fast-stemmer (1.0.0)
  * ffi (1.0.11)
  * fssm (0.2.7)
  * haml (3.1.4)
  * jekyll (0.11.0)
  * kramdown (0.13.4)
  * liquid (2.2.2)
  * maruku (0.6.0)
  * posix-spawn (0.3.6)
  * pygments.rb (0.1.3)
  * rack (1.4.0)
  * rake (0.9.2.2)
  * rb-fsevent (0.4.3.1)
  * rdiscount (1.6.8)
  * rubypants (0.2.0)
  * rubypython (0.5.3)
  * sass (3.1.12)
  * sinatra (1.2.6)
  * stringex (1.3.0)
  * syntax (1.0.0)
  * tilt (1.3.3)

@ghost
Copy link

ghost commented Jan 17, 2012

Looks like you have to downgrade rubypython to 0.5.1. Here's my gems:

Gems included by the bundle:
  * RedCloth (4.2.9)
  * albino (1.3.3)
  * blankslate (2.1.2.4)
  * bundler (1.0.21)
  * chunky_png (1.2.5)
  * classifier (1.3.3)
  * compass (0.11.7)
  * directory_watcher (1.4.1)
  * fast-stemmer (1.0.0)
  * ffi (1.0.11)
  * fssm (0.2.8.1)
  * haml (3.1.4)
  * jekyll (0.11.0)
  * kramdown (0.13.4)
  * liquid (2.2.2)
  * maruku (0.6.0)
  * posix-spawn (0.3.6)
  * pygments.rb (0.1.3)
  * rack (1.4.0)
  * rake (0.9.2.2)
  * rb-fsevent (0.4.3.1)
  * rdiscount (1.6.8)
  * rubypants (0.2.0)
  * rubypython (0.5.1)
  * sass (3.1.12)
  * sinatra (1.2.6)
  * stringex (1.3.0)
  * syntax (1.0.0)
  * tilt (1.3.3)

@Gonzih
Copy link

Gonzih commented Jan 17, 2012

@capsensitive now it works fine, thanks a lot!

@ghost
Copy link

ghost commented Jan 17, 2012

It indeed is weird - When I tried to combine pygments.rb 0.1.3 with rubypython 0.5.3, bundle complains that these two gems are not compatible: pygments.rb 0.1.3 requires rubypython 0.5.1. Maybe I was sleepy last night and I misinterpreted that error msg. Sorry.

I actually lock rubypython to 0.5.1 in Gemfile.lock (just figure that out).

Hope that can help. this morning I just pull octopress master and merged it into my own branch, and everything seems alright.

@rolinh
Copy link

rolinh commented Jan 17, 2012

I tried to rollback rubypython version but I still got the problem. Here is my list of gems:

albino (1.3.3)
blankslate (2.1.2.4)
bundler (1.0.21 ruby)
chunky_png (1.2.5)
classifier (1.3.3)
compass (0.11.7)
directory_watcher (1.4.1)
fast-stemmer (1.0.0)
ffi (1.0.11)
fssm (0.2.8.1)
haml (3.1.4)
jekyll (0.11.0)
kramdown (0.13.4)
liquid (2.2.2)
maruku (0.6.0)
posix-spawn (0.3.6)
pygments.rb (0.1.3)
rack (1.4.0)
rake (0.9.2.2)
rb-fsevent (0.4.3.1)
rb-inotify (0.8.8)
rdiscount (1.6.8)
RedCloth (4.2.9)
rubypants (0.2.0)
rubypython (0.5.1)
sass (3.1.12)
sinatra (1.2.6)
stringex (1.3.0)
syntax (1.0.0)
tilt (1.3.3)

So... same as yours exactly and I still got the same issue.

@ghost
Copy link

ghost commented Jan 17, 2012

@rolinh Sorry, I have no idea :-(
What's your ruby version? Mine is 1.9.2-head. Are you using rvm? Have you installed python2-pygments?

Also, Is your octopress up-to-date? I got an older version of octopress from @roylez, which can generate hilight by default, but after bundle update, it can no longer work. I remember I tried to downgrade rake to 0.9.2 (not 0.9.2.2). That's all information I has so far.

@rolinh
Copy link

rolinh commented Jan 17, 2012

That's OK ;-) Thanks for informing us about a solution that works for you!
Here is my ruby version:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
And yes, I have python2-pygments (1.4-5)

@eldios
Copy link

eldios commented Feb 3, 2012

I finally found where was the bug :) it was rubypython's fault and I'm now working flawlessly with pygmente.rb 0.2.4 and rubypython 0.5.3.

I only had to change the following file:
/var/lib/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/pythonexec.rb

like so:
-- 126 %x(#{@python} -c "#{command}").chomp if @python
++126 %x("#{@python} -c #{command}").chomp if @python

looks like they completely changed the python execution (at last) and it's quite more effective now. Still this is a pretty decent workaround as for now.. let me knw if this helps anybody of you :)

cheers

@rolinh
Copy link

rolinh commented Feb 3, 2012

Wow: I can confirm that this fixes the bug! Thank you so much, you made my day!

@ghost
Copy link

ghost commented Feb 3, 2012

@eldios It works! Thanks!
though I encounter this message (not an error, since octopress generated site successfully

sh: /usr/bin/python2.7 -c import sys; print '%d.%d' % sys.version_info[:2]: No such file or directory
sh: /usr/bin/python2.7 -c import sys; print sys.prefix: No such file or directory

@ab5tract
Copy link

ab5tract commented Feb 9, 2012

Hmm, I'm still getting this error using @eldios' workaround. ArchLinux i686. I'm encountering this issue while attempting to require github's Linguist.

@ab5tract
Copy link

My solution was to set @library manually, rather than relying on the find_python_lib method.

I also set python_executable to 'python2' manually. This is all in the gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/pythonexec.rb file.

@rash-pro
Copy link

I can confirm on Arch x86_64 that the changes made by @ab5stract works just fine!

@ghost
Copy link

ghost commented Mar 20, 2012

I'm on Arch x86_64 I had to do two things. First was to follow @eldios advise about patching pythonexec.rb, the second was to do what @ab5tract mentioned.

The reason find_python_lib isn't working is it doesn't know what to even look for. Top of the function has the following.

libbase = "#{FFI::Platform::LIBPREFIX}#{@basename}"
libext = FFI::Platform::LIBSUFFIX

Which should return something like libpython2.7.so, but what I'm getting back is lib.so. So later down the function it's searching for lib.so in each path and when it realizes that doesn't exist it's returning nil.

So when you do @library = "/usr/lib/libpython2.7.so" like mentioned above it's working fine. So that leads to an FFI problem.

@29x10
Copy link

29x10 commented Apr 2, 2012

here is my gem

addressable (2.2.7)
albino (1.3.3)
blankslate (2.1.2.4)
bundler (1.1.3)
chunky_png (1.2.1)
classifier (1.3.3)
compass (0.11.5)
directory_watcher (1.4.0)
fast-stemmer (1.0.0)
ffi (1.0.9)
fssm (0.2.7)
haml (3.1.2)
heroku (2.23.0)
jekyll (0.11.0)
kramdown (0.13.3)
launchy (2.1.0)
liquid (2.2.2)
maruku (0.6.0)
mime-types (1.18)
netrc (0.7.1)
posix-spawn (0.3.6)
pygments.rb (0.1.3)
rack (1.3.2)
rake (0.9.2)
rb-fsevent (0.4.3.1)
rdiscount (1.6.8)
RedCloth (4.2.8)
rest-client (1.6.7)
rubygems-bundler (0.2.8)
rubypants (0.2.0)
rubypython (0.5.1)
rubyzip (0.9.6.1)
sass (3.1.5)
sinatra (1.2.6)
stringex (1.3.0)
syntax (1.0.0)
tilt (1.3.2)
/usr/lib $ls -alh /usr/lib/libpython*so*
-r-xr-xr-x. 1 root root 1.6M Oct 27 09:36 /usr/lib/libpython2.7.so.1.0

after installed python-pygments, it still not working.
then i install the python-devel,it works

@29x10
Copy link

29x10 commented Apr 2, 2012

after install the python-devel

~/octopress $ls -alh /usr/lib/libpython*so*
lrwxrwxrwx  1 root root   19 Apr  2 12:12 /usr/lib/libpython2.7.so -> libpython2.7.so.1.0
-r-xr-xr-x. 1 root root 1.6M Oct 27 09:36 /usr/lib/libpython2.7.so.1.0

@akzhan
Copy link

akzhan commented May 18, 2012

Should be fixed in rubypython 0.6.1 by https://bitbucket.org/raineszm/rubypython/changeset/f63756cd2a4d

Just released today.

@akzhan
Copy link

akzhan commented May 18, 2012

While this PR isn't accepted, fell free to use :git option in Gemfile.

@akzhan
Copy link

akzhan commented May 19, 2012

Just updated GitLabHQ to eliminate this issue using proposed PR #26.

@buyhome
Copy link

buyhome commented Jul 26, 2012

@capsensitive well done..

@kfirlavi
Copy link

kfirlavi commented Nov 6, 2012

in octopress I have changed the line in the Gemfile
from:
gem 'pygments.rb', '> 0.2.12'
to:
gem 'pygments.rb', '
> 0.3.2'

then ran:
bundle update

This allow pygments use rubypython 0.6.3

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