require 'gem' does not work in ubuntu 10.04 - ruby

ruby1.9.1-full
rubygems1.9.1
installed, these are the only versions i have installed.
I am not able to require any gems with the following syntax:
require 'rubygems'
require 'gem_name'
I get this error:
LoadError: no such file to load -- active_record
from (irb):2:in `require'
from (irb):2
from /usr/bin/irb:12:in `<main>'
I have to add this line to the syntax in order for it to work:
require 'rubygems'
gem 'gem_name' <---
require 'gem_name'
But with gems like active_record and sqlite3 i get this error:
Gem::LoadError: Could not find RubyGem sqlite3 (>= 0)
from /usr/local/lib/site_ruby/1.9.1/rubygems.rb:779:in `report_activate_error'
from /usr/local/lib/site_ruby/1.9.1/rubygems.rb:214:in `activate'
from /usr/local/lib/site_ruby/1.9.1/rubygems.rb:1082:in `gem'
from (irb):3
from /usr/bin/irb:12:in `<main>'
I have been searching and posting but i am still unable to find a solution for this, in a previous installation i had of ubuntu same version as now, i was able to require the gems normally, i'm not quite sure what could have changed.
I hope some one can help me on this one as this has me stuck.
Thanks in advance.
Jaime.

The proper gem name is sqlite3-ruby, not sqlite. Perhaps try gem'ing this instead?

could try it without gem prelude: https://github.com/rdp/ruby_tutorials_core/wiki/ruby-talk-faq#gem_loading_fails_191

Related

Unable to activate wordnet - require 'wordnet' fails

I am writing a Ruby script, and I would like to use wordNet to stem String. I want to give it a string that may contain words of the same form and get back the string but after stemming it. I came across Ruby-WordNet and installed wordnet gem and wordnet-defaultdb gem. I also installed Sequel since it is required.
However, I am not sure how to deal with it. When I typed in the script:
require 'rubygems'
require 'sequel'
require 'wordnet'
I get the following error:
/Users/arwa/.rvm/rubies/ruby- 2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2112:in `raise_if_conflicts': Unable to activate wordnet-1.0.0, because sequel-4.24.0 conflicts with sequel (~> 3.38) (Gem::ConflictError)
from /Users/arwa/.rvm/rubies/ruby- 2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1280:in `activate'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems.rb:198:in `rescue in try_activate'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems.rb:195:in `try_activate'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in require'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from ./test.rb:5:in `<main>'
If I removed
require 'sequel'
I get the following error:
/Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require': cannot load such file -- sequel (LoadError)
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /Users/arwa/.rvm/gems/ruby-2.2.1/gems/wordnet-1.0.0/lib/wordnet.rb:5:in `<top (required)>'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/arwa/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from ./test.rb:4:in `<main>'
I am not sure what is the problem and how to deal with it.
Does any one have any idea on how it works?
Also, if someone can direct me to a place where I can find example on how to code it and to deal with it.
Many thanks in advance.
The error says you have a version conflict.
See what gem list sequel --all says. Odds are good you loaded only the latest version of Sequel by using gem install sequel without specifying the version, or that you have two versions, the one specified by WordNet and the latest
Try removing/uninstalling all Sequel versions installed and reinstall only the specific version:
gem install sequel -v3.38
You can also try modifying the gem requirements for WordNet to not require a specific version of Sequel. Sequel is extremely stable so that should be a safe move.
You have conflicting gem versions installed:
require 'rubygems'
gem 'sequel', '3.48'
require 'sequel'
require 'wordnet'
Will solve your issue.
You can help yourself with a Gemfile. Run bundle init to create one. Run gem install bundler if you have no bundler.
Gemfile:
source "https://rubygems.org"
gem 'sequel'
gem 'wordnet'
Run bundle after you saved your Gemfile. Check Gemfile.lock for the solution.

require 'rubygems' and requre 'RedCloth' is not working. How can I fix it?

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.

Why cant I load sys-proctable?

I have installed the sys-proctable gem on a fresh Ubuntu image (running via Vagrant)
with Ruby 1.8.7.
vagrant#precise64:~$ gem list
*** LOCAL GEMS ***
bunny (0.7.9)
chef (10.14.2)
...many, many gems more
sys-proctable (0.9.3 universal-linux)
systemu (2.5.2)
treetop (1.4.10)
uuidtools (2.1.3)
yajl-ruby (1.1.0)
now I want to load it into irb
vagrant#precise64:~$ irb
irb(main):001:0> require 'sys/proctable'
LoadError: no such file to load -- sys/proctable
from (irb):1:in `require'
from (irb):1
from :0
so what is the issue here?
You may need to require rubygems first. I think then it will work.
Also: are you sure you need to use a / and not a -?
Obviously you managed to load it...
Just wanted to make sure everything is written.
It's definitely a / that's required.
This should work :
require 'rubygems'
require 'sys/proctable'
....

Error while running irb file

This is my first program :
require 'rubygems'
require 'watir'
ie = Watir::IE.new
ie.goto("http://www.google.com")
ie.text_field(:name, "question").set("microsoft")
ie.button(:name, "btnG").click
When I run it,I get the following error, could you please help. I have installed watir-webdriver before running this
C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- watir (LoadError)
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/FirstSample:2:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
My guess is that the problem is caused by the fact that you have installed watir-webdriver gem but you are requiring watir gem.
Either install watir gem or require watir-webdriver gem in your code.
I've just replied to your other question with a sample project and instructions regarding DevKit installation.
Note that RubyMine needs a valid Gemfile to manage dependencies. All the gems that you are using should be specified in that file. bundle install should install the dependencies without errors.
If you have errors installing gems, post it as a separate question with more details, but before doing it verify that DevKit was installed properly and can build/run the sample gem from the installation guide.
Some gems may be not fully compatible with the recently released Ruby 2.0 version. If you have no luck getting it to work, try Ruby 1.9.3 instead.

require 'ruby-debug' LoadError: symbol not found

I've somehow broken my ruby configuration, and I'm not sure how to fix it. Here's an irb session:
>> require 'ruby-debug'
LoadError: dlsym(0x101a272d0, Init_ruby_debug): symbol not found - /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle
from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby-debug-base.rb:1
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-0.10.3/cli/ruby-debug.rb:5
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):1
Here's my ruby version:
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10]
I'm not sure how to go about diagnosing and fixing this. Any suggestions? What other info should I provide?
Reinstalling the gem didn't fix it:
$ sudo gem install ruby-debug
Password:
Successfully installed ruby-debug-0.10.3
1 gem installed
Installing ri documentation for ruby-debug-0.10.3...
Installing RDoc documentation for ruby-debug-0.10.3...
maybe it's missing some dependency .so file? I would use ldd -l to determine this in linux, dunno about mac.
Doing a fresh install of 1.8.7 via rvm fixed this problem for me.

Resources