Sarah Allen
2009-Feb-13 16:42 UTC
can''t find gems in /vendor/gems/ after modifying load_paths
I''m picking up a Rails app that is using a lot of older gems. We''re using Rails 2.0.2 and planning to move to to Rails 2.3 along with upgrading the the dependencies. However, in the meantime, we''re moving servers around and adding new folks to the dev team, so I thought it wise to "freeze" the gems. I''m trying to follow the methodology described here: http://errtheblog.com/posts/50-vendor-everything and here: http://wiki.joyent.com/shared:kb:installing-rails Unfortunately, the gems don''t seem to be found. Here''s what I did... I had all the old gems installed to ~/.gems and all the tests passed. Then I unpacked the gems into /vendor/gems cd ~/rails/vendor/gems gem unpack exifr gem unpack rmagick gem unpack tzinfo gem unpack uuidtools I added the following to config/enviroment.rb inside Rails::Initializer.run do |config| config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir| File.directory?(lib = "#{dir}/lib") ? lib : dir end # print out my load_paths for debugging config.load_paths.each do |p| puts p end and later: require ''rubygems'' gem ''exifr'', ''=0.10.6'' gem ''uidtools'', ''=1.0.2'' gem ''rmagick'', ''=1.15.8'' gem ''tzinfo'', ''=0.3.5'' Here''s what happens: $rake test:units (in /home/sallen/rails) /home/sallen/rails/test/mocks/development /home/sallen/rails/app/controllers/ /home/sallen/rails/app /home/sallen/rails/app/models /home/sallen/rails/app/controllers /home/sallen/rails/app/helpers /home/sallen/rails/config /home/sallen/rails/lib /home/sallen/rails/vendor /home/sallen/rails/config/../vendor/rails/railties/lib/../builtin/rails_info/ /home/sallen/rails/vendor/gems/exifr-0.10.6/lib /home/sallen/rails/vendor/gems/tzinfo-0.3.5/lib /home/sallen/rails/vendor/gems/rmagick-1.15.8/lib /home/sallen/rails/vendor/gems/uuidtools-1.0.2/lib rake aborted! Could not find RubyGem exifr (= 0.10.6) (See full trace by running task with --trace) $ ls vendor/gems/ exifr-0.10.6 rmagick-1.15.8 tzinfo-0.3.5 uuidtools-1.0.2 I must be missing something basic. Any ideas? Thanks in advance, Sarah -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Jones
2009-Feb-14 20:09 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
On Feb 13, 11:42 am, Sarah Allen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m picking up a Rails app that is using a lot of older gems. We''re > using Rails 2.0.2 and planning to move to to Rails 2.3 along with > upgrading the the dependencies. However, in the meantime, we''re moving > servers around and adding new folks to the dev team, so I thought it > wise to "freeze" the gems. I''m trying to follow the methodology > described here:http://errtheblog.com/posts/50-vendor-everything > and here:http://wiki.joyent.com/shared:kb:installing-rails > > Unfortunately, the gems don''t seem to be found. > > Here''s what I did... I had all the old gems installed to ~/.gems and all > the tests passed. Then I unpacked the gems into /vendor/gems > > cd ~/rails/vendor/gems > gem unpack exifr > gem unpack rmagick > gem unpack tzinfo > gem unpack uuidtools > > I added the following to config/enviroment.rb inside > Rails::Initializer.run do |config| > > config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir| > File.directory?(lib = "#{dir}/lib") ? lib : dir > end > # print out my load_paths for debugging > config.load_paths.each do |p| > puts p > end > > and later: > require ''rubygems'' > gem ''exifr'', ''=0.10.6'' > gem ''uidtools'', ''=1.0.2'' > gem ''rmagick'', ''=1.15.8'' > gem ''tzinfo'', ''=0.3.5'' > >Take a careful look at the errtheblog article - you should be using require, not gem here. The gem statements only add the gem directories to the load_path. In the long run, you should definitely switch over to using config.gem, but that isn''t an option with Rails 2.0.3. BTW, even changing to ''require''s is still going to leave you with problems, as RMagick''s native component hasn''t been built yet. I don''t know of any easy way to do it in your situation. You might want, for the short term, to just leave the ''gem'' lines in your environment and keep the gem packages for the gems you need around. That way, the code will complain loudly if the gems needed aren''t installed. --Matt Jones --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sarah Allen
2009-Feb-14 21:07 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
Matt Jones wrote:> Take a careful look at the errtheblog article - you should be using > require, not gem here. > The gem statements only add the gem directories to the load_path.Changing to ''require'' got past that error. I still don''t understand why it failed to load since I had requires elsewhere that just didn''t specify the version. Where would I look up the syntax reference for ''gem'' and ''require'' ? I''m not really clear where those come from. I see ''require'' documented here: http://www.rubygems.org/read/chapter/3 but it doesn''t reference the version argument and I don''t see where ''gem'' is documented.> In the long run, you should definitely switch over to using > config.gem, but that isn''t an > option with Rails 2.0.3.I''ll give that a look when we upgrade.> BTW, even changing to ''require''s is still going to leave you with > problems, as RMagick''s > native component hasn''t been built yet. I don''t know of any easy way > to do it in your > situation.Thanks for the warning.> You might want, for the short term, to just leave the ''gem'' > lines in your environment > and keep the gem packages for the gems you need around. That way, the > code will complain > loudly if the gems needed aren''t installed.Hmmm... so it seems that ''gem'' just declares that the code depends on a gem, and ''require'' actually loads the library? Thanks so much! Sarah -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sean Mcgilvray
2009-Feb-26 21:07 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
Hello everyone, Rails 2.2.2 Gems 1.8 When I add this to my config/environment.rb file my app fails to start. config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir| File.directory?(lib = "#{dir}/lib") ? lib : dir end Does anyone know why that might be happening? Thank You -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Jones
2009-Feb-27 20:57 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
DON''T DO THAT. That''s from a very old tip that no longer applies to current (2.2+) versions of Rails. See this link: http://api.rubyonrails.org/classes/Rails/Configuration.html#M002480 --Matt Jones On Feb 26, 4:07 pm, Sean Mcgilvray <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello everyone, > > Rails 2.2.2 > Gems 1.8 > > When I add this to my config/environment.rb file my app fails to start. > > config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir| > File.directory?(lib = "#{dir}/lib") ? lib : dir > end > > Does anyone know why that might be happening? > > Thank You > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sean Mcgilvray
2009-Feb-27 21:22 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
Matt: Thank you for your reply. I have put this in the environment.rb file and my app fails to start? config.gem ''cyu-ar_mailer'', :lib => ''ar_mailer'', :source => ''http://gems.github.com'' Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Jones
2009-Feb-28 23:20 UTC
Re: can''t find gems in /vendor/gems/ after modifying load_paths
"Fails to start" is not very helpful - what error message do you get? It''ll be helpful to know what version of Rails you''re running, and the output of ''rake gems''. If that errors out, try ''rake gems --trace'' to get a detailed error. --Matt Jones On Feb 27, 4:22 pm, Sean Mcgilvray <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Matt: Thank you for your reply. I have put this in the environment.rb > file and my app fails to start? > > config.gem ''cyu-ar_mailer'', :lib => ''ar_mailer'', :source => > ''http://gems.github.com'' > > Thanks > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---