Ruby debugger opens on kernel_require.rb not file specified - ruby

I'm working through Beginning Ruby and am doing the first exercise with the debugger. It has me running ruby -r debug debug_test.rb. The debugger does launch, but not on the file I specified (I've tried several). Instead I get:
Debug.rb
Emacs support available.
/home/henry/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter
I'm not really sure the implications of this, and google provides no insight. In any case, I thought this might be of some use:
(rdb:1) list
[52, 61] in /home/henry/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb
52 if Gem::Specification.unresolved_deps.empty? then
53 begin
54 RUBYGEMS_ACTIVATION_MONITOR.exit
55 return gem_original_require(path)
56 ensure
=> 57 RUBYGEMS_ACTIVATION_MONITOR.enter
58 end
59 end
60
61 # If +path+ is for a gem that has already been loaded, don't
(rdb:1) var local
found_specs => nil
le => nil
load_error => nil
names => nil
path => "debug"
spec => nil
valid => nil
(rdb:1)
While debug_test.rb does not require any gems, considering the mention of rubygems I thought my rvm gemset might be causing the problems. To this end I tried repeating the procedure with newly created (empty) gemset, but the problem persists. After this I tried running with a different version of ruby (1.9.3), where again the error persists. Interestingly it seems that for 1.9.3 the file does not exist:
/home/henry/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:57:
(rdb:1) list
[52, 61] in /home/henry/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb
No sourcefile available for /home/henry/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb
Any help is much appreciated!

I am not seeing this currently 1.9.3p448 with There are many things going on here that may be conspiring against you.
It is sad that Beginning Ruby recommends using this debugger. I bet just about any other one you use, ruby-debug, pry, byebug, trepan won't have this feature. I suppose Beginning Ruby recommends that module because "debug.rb" comes with Ruby, but it is by far not a debugger one would use as a primary debugger.
And then Ruby has changed over time in the way it handles requires. So probably when Beginning Ruby was written (what is the copyright of the edition you are using?) this feature didn't exist, but now it does. I am pretty sure that if you go back to Ruby 1.8 you won't see this. Probably if you go forward to Ruby 2.x you won't see this either.

Related

DL is deprecated, please use Fiddle

I just installed a ruby 2.2.1 and got this warning when I ran bundle install:
DL is deprecated, please use Fiddle
I came to this question and found the code they pointed out in rbreadline.rb line 4367.
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
I then added the require 'irb' line next to the require 'dl' line as they suggested but this did not remove the warning for me. I realize this may only be a warning but I do not want to comment out the message only to have other problems spring up latter. How do I fix this?
There was a broken version of RubyInstaller that was distributed for about 5 hours.
There were only about 800 downloads of it before someone caught it, but it appears that you are running one of those downloads.
Sorry about that.
Check out the mailing list announcement for more details.
The fix is to re-install using the fixed distribution.

Migrating to rubinius

I'm trying to migrate my project from mri to rubinius to get concurrency advantage.
I've started the server and open first page and then got error:
Puma caught this error: undefined method `=~' for Pathname (NameError)
kernel/common/module.rb:212:in `instance_method'
kernel/common/module.rb:354:in `undef_method'
kernel/bootstrap/array.rb:66:in `each'
kernel/common/module.rb:352:in `undef_method'
...
My Gemfile
source 'https://rubygems.org'
ruby '2.1.0', :engine => "rbx", engine_version: '2.2.1'
gem "rubysl" # Ruby Standard Library meta-gem for rubinius
# Server requirements
gem 'puma'
...
What might be a problem here?
UPDATE: full stack trace
I examined your stack trace and looked at the Rubinius source code. The offending line is:
class Pathname
undef =~ # THIS IS IT
end
#=~ is an instance method on Object so normally undef =~ should work on any class... unless it has been undef'd on Object or on Pathname already.
I'm wondering if this is happening because you have the rubysl gem in your Gemfile. I don't know Rubinius, but from what I can see, it doesn't seem to require you to specifically include this gem. Or maybe it did in past versions, but doesn't now. If the standard library is being loaded twice, that would explain why undef =~ fails the second time.
If that doesn't help, I recommend you try temporarily removing as many gems as possible and see if the problem disappears. If so, add them back one by one until you find which one is causing the problem.

Ruby - 'require': 127: The specified procedure could not be found (LoadError)

So, I have a small Ruby program, which is a simple "Hello World" - the code is below
require 'ray'
Ray.game 'Hello world!', :size => [800, 600] do
register { add_hook :quit, method(:exit!) }
scene :hello do
#text = text 'Hello, Ruby!', :angle => 30, :at => [100, 100], :size => 30
render { |win| win.draw #text }
end
scenes << :hello
end
and it worked just fine on my Win7-32 bit machine. However, when I took the exact same program to my Win7-64 bit machine, the Ruby interpreter spitted out the following message:
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 127:
The specified procedure could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1
/gems/ray-0.2.0/lib/ray_ext.so (LoadError)
From the error message, it seemed like the "ray_ext.so" was missing, but actually it was there:
Both PCs have the exact same version of Ruby (1.9.3), and exact same list of gems installed, yet how come the exact same program worked just fine on the 32-bit Win7 but failed on the 64-bit Win7?
I tried to re-install the gem (ray) again, as well as updating the gem list, but that didn't resolve the issue. From what I discovered from the web, it seemed that this was a "dll" linkage problem (correct me if I'm wrong), but I didn't know how to fix it (excuse me, I'm still a noob in Ruby), except to re-install the gem - which didn't work.
Is there anything else that I can try? Do you think that this is purely the gem's problem (which is not compatible with Win7-64 bit)?
Thank you for your help.
In short, use latest Ruby.
When I install Jekyll on my Windows 7 64bit, I got the same error (Yes, the version of Ruby is 1.9.3). It didn't disappear until I change my Ruby to 2.0.0 (not 2.0.0-x64).
Although I don't understand Ruby at all, I hope this can solve your problem. Thank you.
I had the problem. I tried setting the right oracle bin path pointing to oci.dll, that didn't work. I copied over the oci.dll to ruby\bin directory and later it gave me another error. I had to copy orauts.dll and there you go...the application worked.
Hope that helps others.

Ruby 2.0.0p0 IRB warning: "DL is deprecated, please use Fiddle"

I just uninstalled my older versions of Ruby, removed all of my gems
(including Rails), and installed Ruby 2.0. In other words, a totally clean re-install. Upon starting IRB, I received this message:
DL is deprecated, please use Fiddle
Note: I'm on a Windows machine.
What does this message mean?
The message you received is common when you have ruby 2.0.0p0 (2013-02-24) on top of Windows.
The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
The source is the Deprecation notice for DL introduced some time ago in dl.rb ( see revisions/37910 ).
On Windows the lib/ruby/site_ruby/2.0.0/readline.rb file still requires dl.rb so the warning message comes out when you require 'irb' ( because irb requires 'readline' ) or when anything else wants to require 'readline'.
You can open readline.rb with your favorite text editor and look up the code ( near line 4369 ):
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
We can always hope for an improvement to work out this deprecation in future releases of Ruby.
EDIT:
For those wanting to go deeper about Fiddle vs DL, let it be said that their purpose is to dynamically link external libraries with Ruby; you can read on the ruby-doc website about DL or Fiddle.
You may want to comment out the DL is deprecated, please use Fiddle warning at
C:\Ruby200\lib\ruby\2.0.0\dl.rb
since it’s annoying and you are not the irb/pry or some other gems code owner
I got this resolution at openshift.com.
Resolution:
This error occurs only on Windows machine with Ruby 2.0.0 version.
Until we officially support Ruby 2.0 please downgrade to Ruby 1.9.
On Windows, you can install Ruby 1.9.3 alongside 2.0. Change your
%PATH% to c:\ruby193\ or whatever directory you installed to prior
to installing the gem.
The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
Solution:
You can ignore this in 3 simple steps.
Step 1. Goto C:\RailsInstaller\Ruby2.1.0\lib\ruby\2.1.0
Step 2. Then find dl.rb and open the file with any online editors like Aptana,sublime text etc
Step 3. Comment the line 8 with '#' ie # warn "DL is deprecated, please use Fiddle" .
That's it, Thank you.
I ran into this myself when I wanted to make a thor command under Windows.
To avoid having that message output everytime I ran my thor application I temporarily muted warnings while loading thor:
begin
original_verbose = $VERBOSE
$VERBOSE = nil
require "thor"
ensure
$VERBOSE = original_verbose
end
That saved me from having to edit third party source files.

Ruby "No Such File To Load - sqlite3" on OS X

I was trying to create a quick little script that would insert data into an SQLite db for me but I can't get past the first few steps.
I have done "sudo gem install sqlite3-ruby", my Ruby version is 1.8.7 (I used the Ruby one click installer from rubyforge.org).
My script is incredibly simple. It looks like this:
#!/usr/bin/ruby -w
require "csv.rb"
require "sqlite3"
begin
CSV.open('updateddata.sql', 'r') do |row|
p row
end
rescue => err
puts "Exception : #{err}"
err
end
It never makes it past the line require "sqlite3". It just errors and tells me that it can't find that file to load.
I don't understand how it won't work even after using the One click installer (which is supposed to have SQLite built into the install).
I'm not even sure where to go from here.
I am not a Ruby developer at all, I just wanted to use it as a learning experience and to quickly complete this task for myself.
Dunno if Ruby in OS X behaves differently, but normally you need to do require 'rubygems' before requiring any gems.
You can also add
export RUBYOPT=rubygems
to your profile.
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/43fc65132487f98e/?pli=1 using sqlite3-ruby gem solved my issue on this

Resources