weixin_39683172
weixin_39683172
2020-11-28 11:20

Fiddle

The gem requires fiddle if version > 1.9, and I have tried ruby 1.9.2p136 and 1.9.2p180. Is there a fiddle gem hiding out there somewhere?

rbtrace internal:lib/rubygems/custom_require:29:in require': no such file to load -- fiddle (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire' from /usr/local/lib/ruby/gems/1.9.1/gems/rbtrace-0.3.7/bin/rbtrace:65:in <module:MsgQ>' from /usr/local/lib/ruby/gems/1.9.1/gems/rbtrace-0.3.7/bin/rbtrace:25:in' from /usr/local/bin/rbtrace:19:in load' from /usr/local/bin/rbtrace:19:in

'

该提问来源于开源项目:tmm1/rbtrace

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

12条回答

  • weixin_39898854 weixin_39898854 5月前

    Are you sure? It exists in 1.9.2-p0 and 1.9.2-p136 for me.

    点赞 评论 复制链接分享
  • weixin_39683172 weixin_39683172 5月前

    Perhaps I am misunderstanding how I am supposed to have fiddle. Is it included with ruby or am I missing a gem? I did notice that the rbtrace gem installed ffi, but that doesn't seem to contain fiddle either. I'm running linux and "locate fiddle" gives me no love.

    Thanks for any help, I'm excited to try rbtrace.

    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前
    
    ~/code/rbtrace (master*) % rvm use 1.9.2-p0
    Using .rvm/gems/ruby-1.9.2-p0
    ~/code/rbtrace (master*) % gem which fiddle
    .rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/fiddle.rb
    
    ~/code/rbtrace (master*) % rvm use 1.9.2-p136
    Using .rvm/gems/ruby-1.9.2-p136
    ~/code/rbtrace (master*) % gem which fiddle
    .rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/fiddle.rb
    
    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    Yes, it is included with 1.9.

    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    What linux are you using, and how did you install 1.9?

    点赞 评论 复制链接分享
  • weixin_39683172 weixin_39683172 5月前

    Thanks for the help.

    I found the library in the ruby source in etc/fiddle, is there something I need to do to install the extension? I just installed ruby 1.9.2p180 from source (I don't use RVM).

    Thanks, Evan

    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    I have no idea. I would imagine it just builds by default, but maybe it skips it if you don't have a required library.

    I would recommend you just use RVM instead.

    Alternatively, you can try this patch:

    
    diff --git a/bin/rbtrace b/bin/rbtrace
    index cccaff2..abf70a4 100755
    --- a/bin/rbtrace
    +++ b/bin/rbtrace
    @@ -43,7 +43,7 @@ module MsgQ
         end
    
         def self.recv_cmd(q, block=true)
    -      MsgQ.enable_interrupt  if RUBY_VERSION > '1.9'
    +      MsgQ.enable_interrupt
    
           msg = EventMsg.new
           ret = MsgQ.msgrcv(q, msg, BUF_SIZE, 0, block ? 0 : IPC_NOWAIT)
    @@ -57,22 +57,26 @@ module MsgQ
    
           msg[:buf].to_ptr.read_string_length(BUF_SIZE)
         ensure
    -      MsgQ.disable_interrupt if RUBY_VERSION > '1.9'
    +      MsgQ.disable_interrupt
         end
       end
    
       if RUBY_VERSION > '1.9'
    -    require 'fiddle'
    +    begin
    +      require 'fiddle'
    
    -    handle = DL::Handle.new
    -      = Fiddle::Function.new(handle['rb_enable_interrupt'],  [], DL::TYPE_VOID)
    -     = Fiddle::Function.new(handle['rb_disable_interrupt'], [], DL::TYPE_VOID)
    +      handle = DL::Handle.new
    +        = Fiddle::Function.new(handle['rb_enable_interrupt'],  [], DL::TYPE_VOID)
    +       = Fiddle::Function.new(handle['rb_disable_interrupt'], [], DL::TYPE_VOID)
    +    rescue LoadError
    +      STDERR.puts "*** unable to require('fiddle'). ctrl+c will not work, use `killall rbtrace` instead"
    +    end
    
         def self.enable_interrupt
    -      .call
    +      .call if 
         end
         def self.disable_interrupt
    -      .call
    +      .call if 
         end
       end
    
    点赞 评论 复制链接分享
  • weixin_39683172 weixin_39683172 5月前

    I'm using Ubuntu 10, and installed with the following

    
    wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
    tar xzvf ruby-1.9.2-p180.tar.gz
    cd ruby-1.9.2-p180
    ./configure
    make
    sudo make install
    
    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    It is likely that fiddle just doesn't get built when libffi is not available on the system. Try install libffi and compiling ruby again.

    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    I found a way to get rid of the fiddle dependency altogether. Give me a few mins to push this patch.

    点赞 评论 复制链接分享
  • weixin_39898854 weixin_39898854 5月前

    Here's the fix: 5cc654d6be705831fd4992d4cbd2ccc6410be251. I pushed a 0.3.8 gem that should be available shortly. Let me know if it works.

    点赞 评论 复制链接分享
  • weixin_39683172 weixin_39683172 5月前

    Works great, thanks! Time to play :)

    点赞 评论 复制链接分享

相关推荐