问题
I'm currently running Ruby 1.9.2p0 on a Windows XP 32-bit machine. Ever since we've upgraded to Ruby 1.9, I cannot get any form of debugging to work at all. I've been told that you need the new ruby-debug19 gem in order to get things running. Problem is, my company's proxy prevents the gem dependency manager from connecting external repositories. That's ok, I'll just download the gem myself and install it locally. The results:
ERROR: Error installing ruby-debug19-0.11.6.gem:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb --with-ruby-include=C:\Ruby192\include
checking for vm_core.h... no
checking for vm_core.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby192/bin/ruby
--with-ruby-dir
--without-ruby-dir
--with-ruby-include=${ruby-dir}/include
--with-ruby-lib
--without-ruby-lib=${ruby-dir}/lib
C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `initialize': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT)
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `open'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `block in connect'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `connect'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:1160:in `request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:239:in `block in read'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:286:in `connect'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:234:in `read'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:128:in `download'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:55:in `block in create_makefile_with_core'
from C:/Ruby192/lib/ruby/1.9.1/tempfile.rb:320:in `open'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
from extconf.rb:20:in `<main>'
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/linecache19-0.5.11 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/linecache19-0.5.11/ext/trace_nums/gem_make.out
Perhaps I'm making unreasonable assumptions as I am fairly new to Ruby but it does look like the installation script is attempting to connect an external repository to grab something. If so, this is absurd, why would I locally install a gem if I was able to do so with the manager automatically? Does anybody know a way that I can install a debugger in a purely local, offline fashion? I appreciate any help.
回答1:
I had exactly the same problem, and I second Luis Lavena - just copy all *.h and *.inc files from your ruby sources to the directory which this command prints out:
ruby -rmkmf -e 'puts Config::CONFIG["rubyhdrdir"] + "/" + "ruby-" + RUBY_VERSION.to_s + "-p" + RUBY_PATCHLEVEL.to_s'
Then the ruby_core_source will find those and happily proceed with install.
回答2:
I had the same issues before, although I'm not behind a proxy. Maybe this solution will help.
The ruby-debug19
gem is dependent on linecache19
and ruby-debug-base19
(and some others as Luis mentioned). Not sure about the latter, but the former does not come with binaries for windows which was the source for my problems.
In order to install correctly locally, you should download the gems to a directory and then perform gem install -l
, as you probably did. All the necessary gems can be downloaded from here.
As linecache19 does not ship with win32 binaries, it will try to "build native extensions" by compiling the source code. This will fail on most windows computers, unless you have VC6 compiler, or alternatively have the dev-kit installed by following this link. This package requires you to install the ruby using the ruby installer for windows. Once the dev-kit is installed, you shouldn't get the failures on "build native extensions".
You can read a nice short overview here.
Hope this helps..
回答3:
ruby-debug for Ruby 1.9 uses certain feature of Ruby 1.9 that is not exposed in the normal headers (internals)
Because of that, ruby-debug will attempt to download a source package that matches your Ruby version and extract these headers during the compilation phase.
I agree that is absurd, but since it uses certain undocumented features of Ruby internal headers, there is no way around.
This is triggered by ruby_core_source gem, which you can inspect its source code here
I would recommend you use your browser to download the exact patchlevel of your version of Ruby (indicated in the output you provided above) and looking at ruby_core_source actions, extract the headers files in the indicated places, see line 38 of ruby_core_source.rb
回答4:
If your using RVM,
you might consider having a look at this URL:- http://isitruby19.com/linecache19 .
Worked for me..
Also,
at a stage, I had to even manually download the gems and use gem install with the "-l" command, to get things working.. The commands for the same are..
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ gem install ruby-debug19-0.11.6.gem -l -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.12
Successfully installed ruby-debug19-0.11.6
2 gems installed
Installing ri documentation for linecache19-0.5.12...
Installing ri documentation for ruby-debug19-0.11.6...
Installing RDoc documentation for linecache19-0.5.12...
Installing RDoc documentation for ruby-debug19-0.11.6...
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ ls
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ gem install ruby-debug-base19-0.11.25.gem -l -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/.
Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.25
1 gem installed
Installing ri documentation for ruby-debug-base19-0.11.25...
Installing RDoc documentation for ruby-debug-base19-0.11.25...
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$
Change appropriately based on your Ruby version( 136, or 180 or.. ). I have just added a similar installation wrt another gem ruby-debug-base19-0.11.25 , for reference.
回答5:
I installed ruby 1.9.3 using exe installer. but i found out how to get this thing to work. I opened file called 'ruby_core.rb
'. because the error was exactly there.
And i found that this portion of code cannot download sources.
#
# Download the headers
#
uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz"
Tempfile.open("ruby-src") { |temp|
temp.binmode
uri = URI.parse(uri_path)
uri.download(temp)
tgz = Zlib::GzipReader.new(File.open(temp, "rb"))
FileUtils.mkdir_p(dest_dir)
Dir.mktmpdir { |dir|
inc_dir = dir + "/" + ruby_dir + "/*.inc"
hdr_dir = dir + "/" + ruby_dir + "/*.h"
Archive::Tar::Minitar.unpack(tgz, dir)
FileUtils.cp(Dir.glob([ inc_dir, hdr_dir ]), dest_dir)
}
}
so i got the link from there, manually created directory which should be inside of the 'ruby_dir
' variable and downloaded all sources by that link to it.
to find out how called this directory, I cut a couple of strings of the code from the top and runned it using IRB through the console.
inc_dir = dir + "/" + ruby_dir + "/*.inc"
hdr_dir = dir + "/" + ruby_dir + "/*.h"
So you all need to check out dir (full path to the mentioned place) and ruby_dir to create a directory for all sources.
good luck!
回答6:
Gem does support proxies. You might fiddle with these two parameters:
--source URL Use URL as the remote source for gems -p, --[no-]http-proxy [URL] Use HTTP proxy for remote operations
回答7:
this was happening to me with OSX 10.6.8 and rvm and the answer below from this page workedgem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/
just change the ruby-1.9.2... to whatever ruby you are using
回答8:
This worked for me
$ echo $rvm_path/src/$(rvm tools strings)
$ rvm @global gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/$(rvm tools strings)
Thanks to http://isitruby19.com/linecache19
来源:https://stackoverflow.com/questions/4169169/installing-ruby-debug19-locally