# Autoload with rubygems?

**URL:** <https://www.ruby-forum.com/t/autoload-with-rubygems/150896>\
**Category:** Ruby\
**Created:** [October 14, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/autoload-with-rubygems/150896 "2008-10-14T19:46:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt\_neuburg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@matt\_neuburg](https://www.ruby-forum.com/u/matt_neuburg)\
**Post date:** [October 14, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/autoload-with-rubygems/150896/1 "2008-10-14T19:46:36Z")

</div>

I’m sure this has been asked before but I couldn’t find an actual  
answer.

This works:

require ‘rubygems’  
require ‘ruby-prof’  
RubyProf.start

This doesn’t:

require ‘rubygems’  
autoload(:RubyProf, ‘ruby-prof’)  
RubyProf.start #=\> LoadError: no such file to load - ruby-prof

What am I doing wrong? I’d like to “weak-link” certain gems so that my  
users don’t have to install a gem unless they encounter the part of my  
code that actually uses it. Thx - m.
