kcott has asked for the wisdom of the Perl Monks concerning the following question:

G'day All,

I keep seeing the file '.dancer' when working with Dancer2. It's in every tutorial but never explained. I've no idea what this file is for.

Any ideas?

— Ken

Replies are listed 'Best First'.
Re: .dancer -- what's it for
by Discipulus (Abbot) on Jan 22, 2021 at 17:20 UTC
    Hello kcot,

    a short search pointed me to perl-dancer-conference-2015-report

    > It is recommended to add an empty .dancer file to your app’s directory, which indicates that this is a Dancer app (other Perl frameworks do similarly).

    also found in Changes and this github issue

    L*

    PS

    In the main doc at BOOTSTRAPPING-A-NEW-APP they list the skeleton files created and you can view also at share/skel github repo where the above fix (the simplest fix of the history! ;) was merged.

    PPS the meaning of this file to be there is exposed in the above github issue:

    > There's no reason why we shouldn't generate this file. It might help move away from the bin/lib directory checks.

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      G'day Discipulus,

      Thanks for taking the time to dig out this information; unfortunately, it gives vague hints but nothing concrete. I appreciate that you're only reporting what you found; I'm not trying to shoot the messenger in any of the following paragraphs.

      It's mentioned as a bug fix; however, I can't find any description of the bug it is supposed to fix. Can you provide a link to the actual bug? I just see #1032 pointing to #1043 and vice versa; I don't see any bug report.

      If .dancer is supposed to identify a Dancer app, I'd have thought that .dancer2 would be more appropriate to identify a Dancer2 app.

      "There's no reason why we shouldn't generate this file." — fair enough, but what's the reason to generate it?

      "It might help move away from the bin/lib directory checks." — what checks? what's wrong with them? why move away from them?

      — Ken

      Yeah. Never did understand, though, what this file was for. So far as I know, nothing tests for it.
Re: .dancer -- what's it for
by 1nickt (Abbot) on Jan 22, 2021 at 23:00 UTC

    Hi Ken, FWIW I never heard of this until today and I've been using Dancer and Dancer2 for some years. I always build up my app directories from scratch though, not using the supplied script. I'm rather sure you can ignore it or cease using it altogether.

    Hope this helps!


    The way forward always starts with a minimal test.

      G'day 1nickt,

      I've had some minimal exposure to Dancer but don't recall ever seeing .dancer associated with that.

      I've just started a new $work project that uses Dancer2. That required a fair bit of reading and this is where .dancer kept appearing.

      I'm also not using the supplied script; but I have been looking at its documented output as a reference source. Some files I'll need with some modifications; some I won't want at all; and then there was .dancer with a huge question mark hanging over it.

      — Ken

        The only thing I can speculate is that it's a marker for the base directory -- but that would be odd since there's a method for that. On the other hand, I do usually always have such a dot-file marking the root of my app installation on the FS, so that scripts know where to look for library paths, and so on. Most of my scripts start with something like:

        BEGIN { use Path::Tiny; my $base = path(__FILE__)->parent; $base = $base->parent until -f "$base/.some-dot-file" or $base->is +_rootdir; unshift @INC, "$base/lib"; }
        ... so that they don't have to know where they live. Possibly .dancer has or once had a purpose like that?


        The way forward always starts with a minimal test.