Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings about constant redefinition when used with Nanoc v4.9.3 #37

Open
moll opened this issue Jul 25, 2018 · 5 comments
Open

Warnings about constant redefinition when used with Nanoc v4.9.3 #37

moll opened this issue Jul 25, 2018 · 5 comments
Labels

Comments

@moll
Copy link

moll commented Jul 25, 2018

Hey,

I'm not sure whether this is Nanoc's or the Guard plugin's fault, but the latest versions give the following warnings when starting nanoc live:

/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/view.rb:18: warning: already initialized constant Nanoc::CLI::Commands::View::DEFAULT_HANDLER_NAME
/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/view.rb:18: warning: previous definition of DEFAULT_HANDLER_NAME was here
/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/show-plugins.rb:75: warning: already initialized constant Nanoc::CLI::Commands::ShowPlugins::PLUGIN_CLASS_ORDER
/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/show-plugins.rb:75: warning: previous definition of PLUGIN_CLASS_ORDER was here
/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/show-plugins.rb:81: warning: already initialized constant Nanoc::CLI::Commands::ShowPlugins::PLUGIN_CLASSES
/home/user/.gem/ruby/2.5.0/gems/nanoc-4.9.3/lib/nanoc/cli/commands/show-plugins.rb:81: warning: previous definition of PLUGIN_CLASSES was here

Functionality seems to work though.

@denisdefreyne
Copy link
Member

This indeed harmless, even though it doesn’t look like it.

I think this might not be easily resolvable in a generic way, because bundle exec nanoc live loads Nanoc and guard, and loading guard makes it load Nanoc again.

One way around it would be to define constants as

FOO = 123 unless defined?(FOO)

… but that is a bit icky.

@denisdefreyne
Copy link
Member

FYI: there is the (experimental) nanoc-live project, which adds a nanoc live command without needing Guard or a Guardfile. It’s still experimental (not super-well tested and does not have notifications, for example) but you’re welcome to try it out!

References:

@gpakosz
Copy link

gpakosz commented Nov 1, 2021

Hitting these as well, see https://gitter.im/nanoc/nanoc?at=617fca50fb8ca0572bf78ffc

The thing with nanoc-live is that it doesn't integrate with LiveReload as far as I know. Which means a setup using guard-nanoc + guard-livereload is still a superior solution

@denisdefreyne
Copy link
Member

I recommend switching to nanoc-live (https://github.com/nanoc/nanoc/tree/main/nanoc-live). It comes with livereload support built-in. To switch to nanoc-live:

  1. Add nanoc-live to your Gemfile: bundle add nanoc-live
  2. Remove guard-nanoc from your Gemfile, and run bundle install

Now, you can use the command nanoc live which will work out of the box.

(You can now also delete your Guardfile if you’re not using it for anything else.)

@gpakosz
Copy link

gpakosz commented Nov 2, 2021

I overlooked nanoc-live comes with LiveReload support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants