Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjohnny preston
246 PointsRequire 'rubygems' > false
Hi,
I got this: Successfully installed awesome_print-1.6.1 Parsing documentation for awesome_print-1.6.1 Done installing documentation for awesome_print after 1 seconds 1 gem installed Annteki-MacBook-Pro:~ ann$ irb 2.2.1 :001 > require 'rubygems' => false
But gem 'awesome_print' true.
What can I do to have the require 'rubygems' go true? Thanks.
1 Answer
Blake White
5,232 PointsThe return value for require doesn't actually tell you whether it loaded or not. Rather it tells you if it loaded for the first time or if it was already loaded. If it does not find something that fits the require statement it will actually throw an exception and fail. In this case rubygems is already loaded by default in your irb environment, so your return value of false is telling you that it has already loaded and no action was taken.
Already loaded
irb(main):001:0> require 'rubygems'
=> false
Not found
irb(main):002:0> require 'notagem'
LoadError: cannot load such file -- notagem
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):2
from /usr/bin/irb:12:in `<main>'
Loading for the first time
irb(main):003:0> require 'json'
=> true