Giter Site home page Giter Site logo

Comments (9)

kjvarga avatar kjvarga commented on August 15, 2024

Hi there,

It sounds like you are running an older version of SitemapGenerator. Or at least the tasks file that is being used could be old. Can you make sure that there isn't a plugin version in your application's vendor/plugins and confirm that it is using v2.0.0 when running the rake tasks (best is to use bundler and run with bundle exec).

I'm not seeing this behaviour with Rails 3.0.7 test app. What version of Rails are you running?

from sitemap_generator.

manuelmeurer avatar manuelmeurer commented on August 15, 2024

I just set up a new Rails 3.0.7 test app and the same thing happens. Even the rake sitemap:install generator seems to run twice:

~/apps/sitemap_generator_test bundle exec rake sitemap:install
(in /Users/me/apps/sitemap_generator_test)
created: config/sitemap.rb
already exists: config/sitemap.rb, file not copied

I am using Ruby 1.9.2-p180 and RVM.
There is no Sitemap Generator plugin or old version installed anywhere... very strange.

from sitemap_generator.

manuelmeurer avatar manuelmeurer commented on August 15, 2024

The same happens for me with Rake 0.9.0 instead of 0.8.7 and with Rails versions 3.0.6, 3.0.8.rc4 and 3.1.0.rc1.
Also, it happens on the production server (Ubuntu 8.04), so I doubt it's a problem with an installed legacy version or similar. It must be my configuration or combination of gems, but I'm not seeing it. Can somebody else please try to confirm this?

from sitemap_generator.

kjvarga avatar kjvarga commented on August 15, 2024

Can you pull from https://github.com/kjvarga/sitemap_generator-test and run your tests and see what you get? The README shows my output running under Ruby 1.9.2. It is a Rails 3.0.7 app. Running under REE 1.8.7 also works as expected.

Also run bundle show sitemap_generator in your failing apps just to double-check that the v2.0.0 gem is being used. I get ouput like this:
[karl@karl-vargas-macbook-pro sg-test (master)]$ bundle show sitemap_generator
/Users/karl/.rvm/gems/ruby-1.9.2-p180/gems/sitemap_generator-2.0.1

BTW I just pushed v2.0.1. It just contains a couple minor fixes...nothing related to your issue.

from sitemap_generator.

manuelmeurer avatar manuelmeurer commented on August 15, 2024

Alright, that did the trick. It was my fault after all... :(

I cloned the test app and got the same results as you did. So I went ahead and added the require 'sitemap_generator/tasks' to the Rakefile in the test app as I did in my app where the error originally appeared, at which time I noticed in the README it should just be done for Rails 2. As soon as I removed the require from the Rakefile, everything worked normally.

I had a quick look at the SG tasks file but couldn't see what makes it execute everything twice if it's included twice (normal behavior?). Maybe there is a quick way to fix this in case other people make the same mistake as me?

Thanks for your quick help in this matter and a great gem! :)

from sitemap_generator.

kjvarga avatar kjvarga commented on August 15, 2024

Thanks Manuel :) Glad you like the gem, and that you got it sorted out. I thought about the Rakefile but dismissed it because I figured that it would not require that file twice...but now it makes sense. In Rails 3 the tasks are added using a Railtie, so the require in the Rakefile will cause the tasks file to be loaded (again). Now I think the documented behaviour of Rake is that when you define a task's dependencies, if the task already has deps defined, the dependencies are added to the existing deps...so I can see how rake sitemap:refresh which depends on sitemap:create could run the create tasks twice. But if you call sitemap:create directly I would expect it to have only run it once. I guess Rake must be doing something that I don't understand yet....

from sitemap_generator.

PikachuEXE avatar PikachuEXE commented on August 15, 2024

I got the same issue now
I am using
Ruby 2.3.1 (MRI)
Rails 4.2.7.1
Sitemap generator 5.2.0

I put the following code in /config/sitemap.rb:

puts "rake task: #{Rake::Task["sitemap:create"].actions}"

Result:

rake task: [#<Proc:0x007f9bd50d1498@/users/pikachuexe/.rvm/gems/ruby-2.3.3/gems/sitemap_generator-5.2.0/lib/sitemap_generator/tasks.rb:50>, #<Proc:0x007f9bd2f8c490@/users/pikachuexe/.rvm/gems/ruby-2.3.3/gems/sitemap_generator-5.2.0/lib/sitemap_generator/tasks.rb:50>]
rake task: [#<Proc:0x007f9bd50d1498@/users/pikachuexe/.rvm/gems/ruby-2.3.3/gems/sitemap_generator-5.2.0/lib/sitemap_generator/tasks.rb:50>, #<Proc:0x007f9bd2f8c490@/users/pikachuexe/.rvm/gems/ruby-2.3.3/gems/sitemap_generator-5.2.0/lib/sitemap_generator/tasks.rb:50>]

I wonder if it's due to
https://github.com/kjvarga/sitemap_generator/blob/master/lib/tasks/sitemap_generator_tasks.rake#L1
is using load not require

from sitemap_generator.

9mm avatar 9mm commented on August 15, 2024

For anyone getting this recently, I'm getting it on ruby 3 and sitemap_generator 6.

The answer is you don't need to include anything in your Rakefile. If you include it then it generates it twice...

from sitemap_generator.

PikachuEXE avatar PikachuEXE commented on August 15, 2024

@9mm
Thanks
I just read README again and found that it's mentioned already... 😬

from sitemap_generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.