I'm new to Ruby and just installed Ruby for Windows.
I want to use the mechanize library (https://github.com/tenderlove/mechanize) and so I'm following the guide at https://github.com/tenderlove/mechanize/blob/master/GUIDE.rdoc.
On the Windows cmd line, I installed mechanize by using the cmd "gem install mechanize".
When I run the following code:
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
I get the error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- net/http/digest_auth (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/1.9.1/mechanize.rb:5:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from helloworld.rb:2:in `<main>'
Anybody know what's going on?
It seems that some dependencies are missing. Try to install the net-http-digest_auth gem.
gem install net-http-digest_auth
If that solves this problem and another (related) pops up, it's probable that you are missing the net-http-persistent gem. If that's the case, you know what to do! Just install it too.
Related
Whenever I try to run my Ruby program I get this error:
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in require': cannot load such file -- ffi_c (LoadError)
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:inrescue in require'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:6:inrescue in '
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:3:in <top (required)>'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:inrequire'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rest-client-1.8.0-x64-mingw32/lib/restclient/windows/root_certs.rb:2:in'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rest-client-1.8.0-x64-mingw32/lib/restclient/windows.rb:7:in require_relative'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rest-client-1.8.0-x64-mingw32/lib/restclient/windows.rb:7:in'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in require'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:inrequire'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rest-client-1.8.0-x64-mingw32/lib/restclient.rb:16:in <top (required)>'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:inrequire'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rest-client-1.8.0-x64-mingw32/lib/rest_client.rb:2:in'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in require'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:inrescue in require'
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from form_response_transfer.rb:3:in [main method]
The program (form_response_transfer.rb) used to work fine, but now, there seems to be some problem with my rest-client gem. I haven't changed any of the code in the program since it last worked, so I'm not sure exactly what I did to cause this error. In general, gems that end with X64-mingw32 have been giving me problems lately (some other examples include nokogiri, sqlite3, and pg). How should I go about trying to fix this error? Could there be some problem with how Ruby is set up on my computer?
Try to uninstall FFI gem
gem uninstall ffi
and then reinstall it with below command:
gem install ffi --platform=ruby
It worked on my side (Win7 x64)
I'm learning Ruby from "Beginning Ruby from Novice to Professional" by Peter Cooper. I am on Chapter 7. I have ruby 2.0 installed. I am facing this error:
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
When trying to run this code:
require 'rubygems'
require 'RedCloth'
r = RedCloth.new("This is a *test* of _using RedCloth_")
puts r.to_html
I'm getting this result:
ruby redcloth.rb
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
Couldn't load 2.0/redcloth_scan
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/case_sensitive_require
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/ext
C:/Ruby200/lib/ruby/site_ruby/2.0.0
C:/Ruby200/lib/ruby/site_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/site_ruby
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/vendor_ruby
C:/Ruby200/lib/ruby/2.0.0
C:/Ruby200/lib/ruby/2.0.0/i386-mingw32
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/RedCloth.rb:13:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from redcloth.rb:2:in `<main>'
Exit code: 1
I already installed ruby gems and RedCloth. They didn't give me an errors. If somebody could shed some light on this topic it would be greatly appreciated.
try this:
goto into C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib
and create a dir named '2.0'.
Then copy redcloth_scan.so from 'C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib' into '2.0' dir.
I installed in past RedCloth with Ruby 1.9.1.
Actually I suspect that RedCloth doesn't work with Ruby 2.0.
On ruby 2.x.x you need to compile the gem.
For example for the windows ruby 2.2.4:
Setup the DevKit (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
Run into command window:
gem install RedCloth --platform=ruby
Goto to your installed RedCloth path
lib\ruby\gems\2.2.0\gems\RedCloth-4.2.9\lib
Create there a new directory called "2.2" and copy the file redcloth_scan.so on it.
If you use the gem RedCloth-4.2.9-x86-mingw32, the redcloth_scan.so contains the ruby 1.9 dependency and it doesn't works with ruby 2.2.4.
While making an application in ruby on rails I got the following error:
ajeet#ajeetpc:~$ rails new first_app
/home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- active_support (LoadError)
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/lib/rails_generator.rb:30:in `<top (required)>'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/bin/rails:16:in `<main>'
Seems like the rails gem is not installed properly. Try to fix it
gem uninstall rails
gem install rails
then run rails new first_app again.
Because of a bug with Float#round in Ruby 1.8.6, I was forced to upgrade to 1.9.3 and boy was that awful. After install, irb didn't work, complaining of a lack of psych. So I tried to install the gem, but it was angry that libyaml didn't exist, so I installed that. Not sure why they weren't included if they were so important.
Now when I use require 'Location.rb' (after having to specify that I actually do want to look in the current folder... using $LOAD_PATH), I get this error:
LoadError: cannot load such file -- crack/xml
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/ap-0.1.1/lib/ap.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/tyre77/Dropbox/Aurora/GMap.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'
What does this mean? Also, when I execute ruby -v, it lists my version as 1.9.3p0 but this is dicking around in 1.9.1? All I want is my irb back and working!
It turned out that Ruby was looking for an XML parser called 'crack'. I don't know why it is referencing 2 versions of Ruby or why these dependencies aren't included in the Ruby build (since irb won't work without them) but to fix I installed the crack gem. sudo gem install crack
you can use
require_relative 'Location.rb'
or
require './Location.rb'
I'm working on some cucumber tests from The Cucumber Book. I've got the code that tries to use a transaction processor and there is a file with the following code:
require 'service_manager'
ServiceManager.start
This is on Mac OS X 10.6.8 using Ruby 1.9.2. When this file executes, I get the following:
no such file to load -- service_manager (LoadError)
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/gpollice/MyCucumber/ATMBookExample/features/support/services.rb:6:in `<top (required)>'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
The service_manager gem is installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems as are other gems that the application uses. Until I added the code for this iteration, there were no problems. I've looked for reasons why the gem is not found and just can't figure out why. Any help would be appreciated.
It appears to be a load path issue.
Is require "rubygems" invoked prior to this require statement?
Also, if you're using bundler, you have to add this gem to your Gemfile, as bundler attempts to sandbox your dependencies. If you're using bundler, try the following after adding the gem to the Gemfile:
bundle exec rake cucumber