I have done an extensive search within the Q&As and have yet to find a solution, I hope you can guys can help.
I am currently attempting the TestFirst (Learn_Ruby TestFirst) and can't even get pass the the first test for 00_hello. When I type in rake before creating the hello.rb as requested I get a long error message- not the one liner error message mentioned in the task.
Input rake
(in /Users/yanique/Desktop/learn_ruby)
/Users/yanique/.rvm/rubies/ruby-2.1.1/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- spec_helper (LoadError)
from /Users/yanique/.rvm/rubies/ruby-2.1.1/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1018:in `block in requires='
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1018:in `each'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1018:in `requires='
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration_options.rb:100:in `each'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/configuration_options.rb:22:in `configure'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:96:in `setup'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:85:in `run'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:70:in `run'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/yanique/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.1/exe/rspec:4:in `<top (required)>'
from /Users/yanique/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `load'
from /Users/yanique/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `<main>'
/Users/yanique/.rvm/rubies/ruby-2.1.1/bin/ruby -S rspec /Users/yanique/Desktop/learn_ruby/00_hello/hello_spec.rb -I/Users/yanique/Desktop/learn_ruby/00_hello -I/Users/yanique/Desktop/learn_ruby/00_hello/solution -f documentation -r ./rspec_config failed
Running gem list
*** LOCAL GEMS ***
bigdecimal (1.2.4)
bundler (1.6.1)
bundler-unload (1.0.2)
diff-lcs (1.2.5)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.3)
rake (10.1.0)
rdoc (4.1.0)
rspec (3.0.0, 2.99.0)
rspec-core (3.0.1, 2.99.0)
rspec-expectations (3.0.1, 2.99.0)
rspec-mocks (3.0.1, 2.99.1)
rspec-support (3.0.0)
rubygems-bundler (1.4.3)
rvm (1.11.3.9)
test-unit (2.1.1.0)
rvm info
ruby-2.1.1:
system:
uname: "Darwin yaniques-air.home 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64"
system: "osx/10.9/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)"
zsh: "/bin/zsh => zsh 5.0.2 (x86_64-apple-darwin13.0)"
rvm:
version: "rvm 1.25.27 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "9 days 2 hours 44 seconds ago"
path: "/Users/yanique/.rvm"
ruby:
interpreter: "ruby"
version: "2.1.1p76"
date: "2014-02-24"
platform: "x86_64-darwin12.0"
patchlevel: "2014-02-24 revision 45161"
full_version: "ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]"
homes:
gem: "/Users/yanique/.rvm/gems/ruby-2.1.1"
ruby: "/Users/yanique/.rvm/rubies/ruby-2.1.1"
binaries:
ruby: "/Users/yanique/.rvm/rubies/ruby-2.1.1/bin/ruby"
irb: "/Users/yanique/.rvm/rubies/ruby-2.1.1/bin/irb"
gem: "/Users/yanique/.rvm/rubies/ruby-2.1.1/bin/gem"
rake: "/Users/yanique/.rvm/rubies/ruby-2.1.1/bin/rake"
environment:
PATH: "/Users/yanique/.rvm/gems/ruby-2.1.1/bin:/Users/yanique/.rvm/gems/ruby- 2.1.1#global/bin:/Users/yanique/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/Users/yanique/.rvm/bin"
GEM_HOME: "/Users/yanique/.rvm/gems/ruby-2.1.1"
GEM_PATH: "/Users/yanique/.rvm/gems/ruby-2.1.1:/Users/yanique/.rvm/gems/ruby-2.1.1#global"
MY_RUBY_HOME: "/Users/yanique/.rvm/rubies/ruby-2.1.1"
IRBRC: "/Users/yanique/.rvm/rubies/ruby-2.1.1/.irbrc"
RUBYOPT: ""
gemset: ""
rvm is a function
yaniques-air:~ yanique$ type rvm | head -n1
rvm is a function
yaniques-air:~ yanique$ rake --version
rake, version 10.1.0
Tried bundle install
yaniques-air:00_hello yanique$ bundle install
Using rake 10.1.0
Using diff-lcs 1.2.5
Using rspec-support 3.0.0
Using rspec-core 3.0.1
Using rspec-expectations 3.0.1
Using rspec-mocks 3.0.1
Using rspec 3.0.0
Using bundler 1.6.1
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
I am expecting a short error when inputting rake without the corresponding hello.rb but definitely not such an extensive error. Nothing seems to be working and I feel I am at an impasse. Sorry for the long post just trying to cover my bases.
Here's the rakefile that was included in the learn_ruby directory (I tried adding require 'ruby gems' to it but that did not help either)
gem 'rspec', '~>2'
require 'rspec/core/rake_task'
task :default => :spec
desc "run tests for this lab"
RSpec::Core::RakeTask.new do |task|
lab = Rake.application.original_dir
task.pattern = "#{lab}/*_spec.rb"
task.rspec_opts = [ "-I#{lab}", "-I#{lab}/solution", '-f documentation', '-r ./rspec_config']
task.verbose = false
end
Any help will be greatly appreciated! Thank you for your time.
Uninstall all the rspec related gems, all versions, then reinstall the last 2.x version
gem install -v '< 3.0.0' rspec
Try rake again from the root directory.
run a ruby script got error `require': cannot load such file -- net/ssh (LoadError)
bash-3.2$ rvm --default ruby-2.0.0-p451
-bash-3.2$ rvm list
rvm rubies
=* ruby-2.0.0-p451 [ x86_64 ]
-bash-3.2$ gem list --local
*** LOCAL GEMS ***
bigdecimal (1.2.0)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
net-ssh (2.9.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.0.0.0)
ruby test.rb
`require': no such file to load -- rubygems (LoadError)
$ cat test.rb
require 'rubygems'
require 'net/ssh'
Net::SSH.start(...)
what's wrong? please advice. thanks
run a ruby code got error "rvm `require': no such file to load -- rubygems (LoadError)"
bash-3.2$ rvm --default ruby-2.0.0-p451
-bash-3.2$ rvm list
rvm rubies
=* ruby-2.0.0-p451 [ x86_64 ]
-bash-3.2$ gem list --local
*** LOCAL GEMS ***
bigdecimal (1.2.0)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
net-ssh (2.9.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.0.0.0)
-bash-3.2$ gem list --local rubygems
*** LOCAL GEMS ***
rubygems-bundler (1.4.2)
to run the script:
ruby test.rb
`require': no such file to load -- rubygems (LoadError)
$ cat test.rb
require 'rubygems'
require 'net/ssh'
Net::SSH.start(.............
what's going on? please advice. thanks
I'm writing Ruby scripts on Linux Mint 14 under RVM. In both Ruby 2.0 and 1.9.3, when I try to run what I'm working on, I get the error:
/home/tom/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- Nokogiri (LoadError)
from /home/tom/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from make_index.rb:1:in `<main>'
Nokogiri is installed; gem list gives:
*** LOCAL GEMS ***
bigdecimal (1.1.0)
bundler (1.3.5)
bundler-unload (1.0.1)
io-console (0.3)
json (1.5.5)
mini_portile (0.5.1)
minitest (2.5.1)
nokogiri (1.6.0)
rake (10.1.0, 0.9.2.2)
rdoc (3.9.5)
rubygems-bundler (1.2.1)
rvm (1.11.3.8)
The file in question starts with require 'Nokogiri'. Running the file with sudo doesn't make a difference, nor does using the terminal vs. running it in Geany.
Not Nokogiri rather, you should write as below
require 'nokogiri'
See SYNOPSIS:
I am trying to run the following ruby code from IRB but am unable to require the gmail gem.
require 'rubygems'
require 'gmail'
gmail = Gmail.new("user", "pass")
Here's the IRB output:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ irb
>> require 'rubygems'
=> false
>> require 'gmail'
NameError: uninitialized constant Gmail
from ./gmail.rb:6
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from (irb):2
Here is Gem.path output:
>> Gem.path
=> ["/Users/johnnygoodman/.gem/ruby/1.8", "/Library/Ruby/Gems/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"]
And environment output:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/johnnygoodman/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gems.github.com
And which ruby:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ which ruby
/usr/bin/ruby
And .gemrc:
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ cat .gemrc
---
:sources:
- http://rubygems.org/
- http://gems.github.com
:backtrace: false
:benchmark: false
:verbose: true
:update_sources: true
:bulk_threshold: 1000
Here's my gemlist:
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.8, 2.3.5, 2.2.2, 1.3.6)
actionpack (2.3.8, 2.3.5, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activerecord (2.3.8, 2.3.5, 2.2.2, 1.15.6)
activeresource (2.3.8, 2.3.5, 2.2.2)
activesupport (2.3.8, 2.3.5, 2.2.2, 1.4.4)
acts_as_ferret (0.4.4, 0.4.3)
Ascii85 (1.0.0)
autotest (4.2.10, 4.2.9)
autotest-fsevent (0.2.2, 0.1.1)
autotest-growl (0.2.4, 0.2.0)
autotest-rails (4.1.0)
bigdecimal-segfault-fix (1.0.1)
capistrano (2.5.18, 2.5.11, 2.5.2)
cgi_multipart_eof_fix (2.5.0)
cheat (1.2.1)
chronic (0.2.3)
configuration (1.1.0)
daemons (1.0.10)
dnssd (1.3.1, 0.6.0)
fastthread (1.0.7, 1.0.1)
fcgi (0.8.8, 0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
gemcutter (0.5.0, 0.4.1)
heroku (1.9.9, 1.8.5)
highline (1.5.2, 1.5.1, 1.5.0)
hoe (2.6.0, 2.5.0)
hpricot (0.8.2, 0.6.164)
json_pure (1.4.3, 1.2.3, 1.2.2)
launchy (0.3.5)
libxml-ruby (1.1.4, 1.1.3, 1.1.2)
mail (2.2.1)
mechanize (1.0.0, 0.9.3)
mime-types (1.16)
mongrel (1.1.5)
mysql (2.8.1)
needle (1.3.0)
net-scp (1.0.2, 1.0.1)
net-sftp (2.0.4, 2.0.1, 1.1.1)
net-ssh (2.0.22, 2.0.21, 2.0.17, 2.0.4, 1.1.4)
net-ssh-gateway (1.0.1, 1.0.0)
nokogiri (1.4.2, 1.4.1)
passenger (2.2.11, 2.2.9)
pdf-reader (0.8.5, 0.8.4, 0.8.3)
polyglot (0.3.1)
pony (1.0, 0.9, 0.6)
rack (1.1.0, 1.0.1)
rails (2.3.8, 2.3.5, 2.2.2, 1.2.6)
rake (0.8.7, 0.8.3)
RedCloth (4.2.3, 4.1.1)
rest-client (1.4.2, 1.3.1)
rspec (1.3.0)
rspec-rails (1.3.2)
ruby-gmail (0.2.1, 0.0.8)
ruby-openid (2.1.7, 2.1.2)
ruby-yadis (0.3.4)
rubyforge (2.0.4)
rubygems-update (1.3.7, 1.3.6, 1.3.5, 1.3.1)
rubynode (0.1.5)
scrapi (1.2.0)
shared-mime-info (0.1)
sqlite3-ruby (1.2.5, 1.2.4)
sys-uname (0.8.4)
termios (0.9.4)
tidy (1.1.2)
tmail (1.2.7.1)
treetop (1.4.5)
xmpp4r (0.5, 0.4)
ZenTest (4.3.1)
I've uninstalled mac ports and used hivelogic instructions to install a fresh ruby/rails version. However, notice that my which ruby doesn't match hivelogic's instructions until I run:
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ . ~/.profile
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ which ruby
/usr/local/bin/ruby
I think this is the problem but am not sure what to read to force the ruby path to always load to /usr/local/bin/ruby. It could also be a red herring as I simply don't know how the parts fit. As soon as sudo gem install doesn't work, I'm basically lost.
Note other gems do work:
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mechanize'
=> true
Questions:
When sudo gem install doesn't allow you to create an object from the class, what are the next steps in sleuthing down the issue?
How do the parts of a gem fit together as applies to fixing these types of issues? I've read the FAQs and docs (http://docs.rubygems.org/read/book/3) but either missed it or was unable to pick out the relevant parts.
Looks like you have some misunderstanding how ruby loads files. There's an include path (check out the $: variable). When you require something, ruby will start at the first path in the array, and checks if the file is there. If it's, then it loads it, otherwise it moves on to the next directory in the include path.
When you require gmail, it looks like that it loads your own gmail.rb. Doing a require "gmail" in that file will find itself, instead of the gem's gmail.rb.
To fix it you should probably rename your gmail.rb to something else (my_gmail.rb, or anything, just make sure it doesn't match any system file).
(The require 'ruby-gmail' fails because the ruby-gmail gem doesn't contain such file. You should use simply require 'gmail', but before that rename your gmail.rb)
Your IRB output seems to be about as far as you needed to go:
>> require 'gmail'
NameError: uninitialized constant Gmail
from ./gmail.rb:6
When you require 'gmail' it's pulling in your local gmail.rb file - within which there's a reference to a Gmail class(?) which isn't defined.
It's unclear why you'd expect Gmail to be defined, though. Without seeing the code in gmail.rb, it's hard to say what's wrong.
I notice that in your gem list there isn't any gem called "gmail" or anything similar.
It's hard to tell, therefore, what you're trying to accomplish. Perhaps you're confusing gems with a basic library require, or are assuming that the Rails constant-lookup functionality is a Ruby feature.
Most useful would be if you could post the contents of gmail.rb.