Thin LoadError: no such file to load thin_parser

青春壹個敷衍的年華 提交于 2019-12-22 09:15:54

问题


I have installed thin and try to do thin start, which end up with this error

C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/1.9/thin_parser (LoadError)
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:48:in `rescue in <top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:43:in `<top (required)>'
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/bin/thin:5:in `<top (required)>'
    from C:/Ruby192/bin/thin:19:in `load'
    from C:/Ruby192/bin/thin:19:in `<main>'

Can someone help me out please, thanks in advance


回答1:


the output denotes a directory called 1.9 i.e.

<ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/1.9/

Note: My thin version is 1.2.10. In the following i will use the path as it appears on my system.

For some reason the thin gem doesn't come with this directory. But a file called thin_parser.so resides in the parent directory <ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.10/lib/

So my first solution was to create a directory 1.9 and copy the file thin_parser.so to it. Now thin start works for me.

Alternatively you can edit the file <ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.10/lib/thin.rb and change

if Thin.win?
  # Select proper binary under Windows
  major_ruby_version = RUBY_VERSION[/^(\d+\.\d+)/]
  require "#{Thin::ROOT}/#{major_ruby_version}/thin_parser"
else
  require "#{Thin::ROOT}/thin_parser"
end

to

if Thin.win?
  # Select proper binary under Windows
  major_ruby_version = RUBY_VERSION[/^(\d+\.\d+)/]
  require "#{Thin::ROOT}/thin_parser"
else
  require "#{Thin::ROOT}/thin_parser"
end

or even simpler

require "#{Thin::ROOT}/thin_parser"

I'm not sure what workaround is the better one, since i don't know what else files thin expects in the not existing directory. I don't know either where the Thin.win? fork becomes important.

I decided in favor of the first solution. But both ways fixed the Problem for me.

Best regards,
Tim




回答2:


I ran into this same error when running rake db:migrate (I suspect thin start would have given me the same error.)

I'm running on Amazon Linux (rpm based, so similar to CentOS and Redhat). I had previously installed thin as root (gem install thin). Although it may be irrelevant to your situation, just for completeness, I had also installed eventmachine using:

gem install eventmachine --platform=ruby

Here is the error I got:

% rake db:migrate
rake aborted!
LoadError: cannot load such file -- thin_parser
/home/rails/.gem/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
etc. etc.

Based on the above information, I ran rake under strace and discovered that it was looking for thin_parser.so in the wrong place. I was able to fix the problem by installing this symbolic link (I did this as root since I installed thin as root). Obviously, adjust the path to where your version of thin is installed:

 cd /usr/local/share/gems1.9/gems/thin-1.6.3/lib
 ln -s ../ext/thin_parser/thin_parser.so .

Poof! That fixed it for me.



来源:https://stackoverflow.com/questions/5380826/thin-loaderror-no-such-file-to-load-thin-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!