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'
....
Related
I am using ruby version 2.3.3p222
Here is my Gemfile:
# Gemfile
source 'https://rubygems.org'
gem 'pry'
I run bundle and here is the resulting Gemfile.lock
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.2)
method_source (0.9.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
PLATFORMS
ruby
DEPENDENCIES
pry
BUNDLED WITH
1.15.1
I then simply run a ruby script via ruby my_report.rb (this script is located in the same directory as Gemfile and Gemfile.lock). my_report.rb only has this in the file:
require 'pry'
Here is the error:
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-rescue-1.4.5/lib/pry-rescue.rb:15: warning: method BaseHelpers#windows? is deprecated. Use Pry:Helpers::Platform.windows? instead
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer.rb:128:in `<top (required)>': undefined method `before_command' for #<Pry::CommandSet:0x007fccdcf0b1e8> (NoMethodError)
Question: What am I missing? How can I properly require in pry into my ruby script so that I can set breakpoints?
What eventually worked for me is I just uninstalled all of the pry versions I had installed via gem uninstall. Then: in my gemfile I specified a previous version of 0.11.3:
# Gemfile
source 'https://rubygems.org'
gem 'pry', '0.11.3'
I did bundle install and then ran my ruby script, and that worked for me.
I want to use rbgccxml with Ubuntu Precise. This gem requires nokogiri. Thus, I installed the ruby-nokogiri (v1.5.0) Ubuntu package first. Then I tried to install rbgccxml via 'gem install' but it always tries to install nokogiri (> 1.4) also. To prevent this I used 'gem install --ignore-dependencies rbgccxml'.
$ gem which rbgccxml
/var/lib/gems/1.8/gems/rbgccxml-1.0.3/lib/rbgccxml.rb
$ gem which nokogiri
/usr/lib/ruby/vendor_ruby/nokogiri.rb
Now I get strange behavior. The following script:
require 'nokogiri'
puts 'step 1'
require 'rubygems'
puts 'step 2'
require 'rbgccxml'
puts 'step 3'
outputs:
step 1
step 2
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find nokogiri (~> 1.4.0) amongst [rbgccxml-1.0.3] (Gem::LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:771:in `activate_dependencies'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `each'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `activate_dependencies'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:744:in `activate'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:209:in `try_activate'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:58:in `require'
from test3.rb:8
So, why nokogiri is found by require but not by require inside rbgccxml?
rbgccxml specifies the dependency to nokogiri using the pessimistic version constraint as follows:
gem "nokogiri", "~>1.4.0"
This is equivalent to:
gem "nokogiri", ">= 1.4.0", "< 1.5.0"
This means that rbgccxml requires a version of nokogiri prior to the one you have installed.
If you don’t specifically need nokogiri 1.5.0, then let rubygems resolve and install the dependencies for you.
I've got a simple script that uses sinatra. Should be simple, right? Apparently not.
The code:
require 'rubygems'
require 'sinatra'
That's all there is. And it fails, saying:
tekknolagi#eos ~/indexer $ ruby torrent.rb
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- torrent-ruby (LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from torrent.rb:2
I gem installed it several times over, just to make sure I wasn't going crazy. What could be going wrong and how can I fix it?
Oh, and here's my list of installed gems:
tekknolagi#eos ~/indexer $ gem list
*** LOCAL GEMS ***
rack (1.4.1)
rack-protection (1.2.0)
rake (0.9.2.2)
sinatra (1.3.2)
sqlite3 (1.3.6)
tilt (1.3.3)
torrent-ruby (0.1.4)
I believe you have done everything right. Many times this custom require error appears when the gem is not installed in the proper path. Try not using the explicit require. Use this instead..:
require_relative 'sinatra'
I execute for instance:
gem list
and I get this:
abstract (1.0.0)
actionmailer (3.2.1, 3.1.3, 3.1.1, 3.0.5)
actionpack (3.2.1, 3.1.3, 3.1.1, 3.0.5)
activemodel (3.2.1, 3.1.3, 3.1.1, 3.0.5)
(...)
uglifier (1.2.3, 1.2.2, 1.1.0, 1.0.3)
webrat (0.7.3)
xpath (0.1.4)
Them if I try with
irb --simple-prompt
>> require 'webrat'
I get
LoadError: no such file to load -- webrat
from (irb):1:in `require'
from (irb):1
from :0
And this happens with every Gem on the list. What's wrong? I'm using Ubuntu 11.10. Sorry if this is dumb, but I got stuck.
You need to require rubygems before you can require any gems. You can do this in irb:
$ irb --simple-prompt
>> require 'rubygems'
>> require 'webrat'
or when starting irb up:
$ irb --simple-prompt -r rubygems
>> require 'webrat'
Ruby 1.9 package now includes RubyGems by default on most platforms.This means that on Ruby 1.9 and above, you will not need to require 'rubygems' in order to load gem libraries.
if you use like this: require 'rubygems'
The big problem with this approach is that you don’t want to make this change to every single Ruby program you download!
While ok for quick scripts you write yourself, this is not the way to go.
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