Custom Gem in / vendor / gems not loading

I recently decided to use some of the features that I have in several of my Rails applications and extract them in Engine. I ended up working with "Engine" and I'm trying to install a ready-made stone in one of my applications.

This particular gem is not what I want to be public, so I packed the gem with gem build my_gem.gemspec, and then placed the packed gem in the vendor / gem folder of my application. Then I added gem 'my_gem', '0.0.1', :path => 'vendor/gems'to my gemfile and launched bundle install.

Unfortunately, Rails does not seem to load the gem, and I cannot require it manually:

$ bundle exec rails console --sandbox
Loading development environment in sandbox (Rails 3.2.11)
Any modifications you make will be rolled back on exit
irb(main):001:0> MyGem
NameError: uninitialized constant MyGem
        from (irb):1
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
irb(main):002:0> require 'my_gem'
LoadError: cannot load such file -- my_gem
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
        from (irb):2
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Am I doing something wrong? How to fix it?


Edit: Here is my gem environment information.

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.16
  - RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [i386-mingw32]
  - INSTALLATION DIRECTORY: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe
  - EXECUTABLE DIRECTORY: c:/RailsInstaller/Ruby1.9.3/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1
     - c:/Users/Ajedi32/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
+5
1

gem env, , Ruby .

, , GEM_PATH. :.

  export GEM_PATH="./vendor/gems:$GEM_PATH"

: http://docs.rubygems.org/read/chapter/12

Gemfile, :

  gem 'my-gem', '0.0.1', :path => 'vendor/gems/my-gem'

( )

+4

All Articles