Topic: how can I pack all gems into app?

Hi all,
I tried to unpack all the gems that my app use into vendor folder so that i can simply copy the whole app into prod server and run it from there without installing any thing (except ruby).

nhut_le@kensei:~/workspace/DB$ gem unpack rails -v=2.3.5

I did that for all the gems I have on my dev machine.
Then copied the whole app to prod. But when i started the server i got error:

ruby script/server -eproduction -d
config.gem: Unpacked gem json_pure-1.2.0 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem actionpack-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem hash_extension-0.0.4 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem daemons-1.0.10 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem actionmailer-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem mysql-2.8.1 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem activesupport-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem linecache-0.43 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem activeresource-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem will_paginate-2.3.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem cgi_multipart_eof_fix-2.5.0 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem activerecord-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem rake-0.8.7 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem mongrel-1.1.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem rails-2.3.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem money-2.1.5 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem fastthread-1.0.7 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rack (~> 1.0.1) (Gem::LoadError)
  from /usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
  from /usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
  from /home/PAS/vendor/rails/actionpack/lib/action_controller.rb:34
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  from /home/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
  from /home/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/PAS/vendor/rails/railties/lib/commands/server.rb:2
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  from script/server:3

Did I miss any step?
Thanks in advance

Re: how can I pack all gems into app?

you forgot the rack gem

Could not find RubyGem rack (~> 1.0.1) (Gem::LoadError)

Re: how can I pack all gems into app?

Thanks, now I have another problem, it doesnt seem that mysql is working after i unpack it into vendor/gems folder. I read somewhere that gems which required native built cant be vendored, rmagick is one example, how about mysql? Has anyone been able to vendor mysql gem?

Re: how can I pack all gems into app?

Actually they can be vendored. I have rmagick unpacked in my app. But I run rake gems:build:force each time I re-deploy it from repository, so it builds native extensions also.

Re: how can I pack all gems into app?

so I must have rake install right? I though prod server just need to have ruby

Re: how can I pack all gems into app?

Have you tried unpacking mysql gem and rebuilding native extensions with rake gems:build:force?

btw, what hosting are you using?

Re: how can I pack all gems into app?

Alex,
I tried to unpack mysql on my dev machine and then do the rake gem:build:force and it works. However, since it's on a dev machine, all the gem are installed to /usr/lib/ruby/gems/1.8, i dont know if the gem:build:force are actually use the mysql locally in vendor/gems/mysql or the mysql gem in /usr/lib/ruby/gems/1.8. I havent tried force rebuilt on prod server yet, i'll do it soon.
I'm not using any hosting service, i's a host the company provide and other than the bare os (RHE 5.2), they dont install anything else. That's why i need everything vendored so that I can simply ask them to install ruby

Re: how can I pack all gems into app?

If you have it vendored, it probably rebuilds the vendored one. No idea what it does is you don't have it vendored.

Re: how can I pack all gems into app?

Alex, i vendored all the gems that i think i use in my app:

ls vendor/gems/
cgi_multipart_eof_fix-2.5.0  hash_extension-0.0.4  rack-1.0.1
daemons-1.0.10               money-2.1.5           rake-0.8.7
fastthread-1.0.7             mongrel-1.1.5         rubygems-update-1.3.5
gem_plugin-0.2.3             mysql-2.8.1           will_paginate-2.3.12

But when i tried

vendor/gems/rake-0.8.7/bin/rake gems:build:force

i got this:

/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- rake (LoadError)
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  from vendor/gems/rake-0.8.7/bin/rake:29

I also tried to start mongrel (expecting to get some errors with mysql gem because i couldnt run rebuild above), but this error show up instead:

ruby script/server mongrel -b192.168.1.65 -p3000 -eproduction
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- http11 (MissingSourceFile)
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/nhut_le/PAS/vendor/gems/mongrel-1.1.5/lib/mongrel.rb:12
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
  from /home/nhut_le/PAS/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
  from /home/nhut_le/PAS/vendor/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:1
  from /home/nhut_le/PAS/vendor/gems/rack-1.0.1/lib/rack/handler.rb:17:in `const_get'
  from /home/nhut_le/PAS/vendor/gems/rack-1.0.1/lib/rack/handler.rb:17:in `get'
  from /home/nhut_le/PAS/vendor/gems/rack-1.0.1/lib/rack/handler.rb:17:in `each'
  from /home/nhut_le/PAS/vendor/gems/rack-1.0.1/lib/rack/handler.rb:17:in `get'
  from /home/nhut_le/PAS/vendor/rails/railties/lib/commands/server.rb:45
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  from script/server:3

So the first question is that if you vendor rake into your app, how do you use it at the command level? secondly, do you have any suggestion for the missing http11 ?
Thanks in advance