Ruby on Rails - rake install/unpack
What's the main difference between:
rake gems:install
rake gems:unpack
I had a problem with it telling me I was missing these gems. I did the rake gems:install. Then I thought I had installed the gems. But it said again , I was missing gems. After I did rake gems:unpack. It fixed the problem. Why is that?
####com@#.com [~/rails_apps/employee_tracker]# rake db:m开发者_如何转开发igrate
(in /home2/#com/rails_apps/employee_tracker) Missing these required gems: authlogic
acl9You're running: ruby 1.8.7.174 at /usr/bin/ruby rubygems 1.3.7 at /home2/#com/.gem/ruby/1.8, /usr/lib64/ruby/gems/1.8
Run rake gems:install
to install the missing gems.
com@#.com [~/rails_apps/employee_tracker]# rake gems:install
(in /home2/#com/rails_apps/employee_tracker) gem install authlogic Successfully installed authlogic-2.1.6 1 gem installed Installing ri documentation for authlogic-2.1.6... Installing RDoc documentation for authlogic-2.1.6... gem install acl9 --source http://gemcutter.org Successfully installed acl9-0.12.0 1 gem installed Installing ri documentation for acl9-0.12.0... Installing RDoc documentation for acl9-0.12.0...
com@#.com [~/rails_apps/employee_tracker]# rake db:migrate
(in /home2/#com/rails_apps/employee_tracker) Missing these required gems: authlogic
acl9You're running: ruby 1.8.7.174 at /usr/bin/ruby rubygems 1.3.7 at /home2/#com/.gem/ruby/1.8, /usr/lib64/ruby/gems/1.8
Run rake gems:install
to install the missing gems.
com@#.com [~/rails_apps/employee_tracker]# rake gems:unpack
(in /home2/#com/rails_apps/employee_tracker) gem install authlogic Successfully installed authlogic-2.1.6 1 gem installed Installing ri documentation for authlogic-2.1.6... Installing RDoc documentation for authlogic-2.1.6... gem install acl9 --source http://gemcutter.org Successfully installed acl9-0.12.0 1 gem installed Installing ri documentation for acl9-0.12.0... Installing RDoc documentation for acl9-0.12.0... Unpacked gem: '/home2/#com/rails_apps/employee_tracker/vendor/gems/authlogic-2.1.6' Unpacked gem: '/home2/#com/rails_apps/employee_tracker/vendor/gems/acl9-0.12.0'
rake gems:install does what you would expect. It calls out to rubygems.org and downloads the gems specified in the Gemfile/environment.rb.
rake gems:unpack unzips the contents of the gems specified in the Gemfile/environment.rb into your vendor/gems folder.
I believe you are just not specifying your gems and just trying to use them without adding them to the project via Gemfile(Rails 3)/environment.rb(Rails 2.X). Anything in vendor/gems is loaded automatically which I think would explain what you are seeing.
You should be putting
config.gem 'name_of_gem'
in your environment.rb file for the gems to be added. Rails3 has a file called Gemfile where you do:
gem 'name_of_gem'
I hope that helps.
精彩评论