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

Documentation 2.0: Describe symlinks #1420

Open
5 tasks
insspb opened this issue May 30, 2020 · 4 comments
Open
5 tasks

Documentation 2.0: Describe symlinks #1420

insspb opened this issue May 30, 2020 · 4 comments
Labels
documentation This issue/PR relates to or includes documentation. please-help This issue/PR contain help request to cookiecutter users or first-time contributors
Milestone

Comments

@insspb
Copy link
Member

insspb commented May 30, 2020

Symlinks can make unexpected things with templates developers and templates users.

So symlinks behaviour should be deeply described and actual defaults should be selected.

Issues and PRs that should be reworked and merged or at least considered:

@insspb insspb added please-help This issue/PR contain help request to cookiecutter users or first-time contributors documentation This issue/PR relates to or includes documentation. labels May 30, 2020
@insspb insspb added this to the 2.0.0 milestone May 30, 2020
@dbzm
Copy link

dbzm commented Sep 30, 2020

I have to confess I'm somewhat confused as to the "intended" behavior of symlinks. I see people saying that they don't want them dereferenced when the repo is stamped, which makes sense.

At the same time, however, without symlinks directories become a whole lot less useful. They're called out in that part of the documentation:

This allows using symlinks for general files.

What is the plan for them going forward?

@samschott
Copy link

samschott commented Jul 7, 2021

To chime in on this, I think there are many project structures, especially targeting Unix-like systems, where symlinks play an essential role and should be copied as-is instead of followed. One example are macOS Frameworks which rely on symlinks in their folder structure.

I've just looked through the docs and can see how symlinks are useful to refer to the same file in multiple templates. However, when there is a choice between convenience in setting up the templates (by following symlinks) and not being able to generate a certain type of project at all (projects containing symlinks, relative or absolute), I would probably prefer the versatility in types of projects that can be created.

A good compromise probably is to have a flag / option. My intuition would say that such a flag should default to copying symlinks as-is. But maybe there is an active user base that relies on resolving symlinks...

@seanh
Copy link

seanh commented Jul 7, 2022

Please don't change the current behavior of following symlinks, at least not without an option to restore the current behavior.. As noted by @dbzm it has been advertised as a feature in the docs. Changing cookiecutter to copy symlinks as symlinks would break our cookiecutters which rely heavily on the current behavior.

Cookiecutters that want to have actual symlinks in the generated project can easily do that with a post-generate hook:

# hooks/post_gen_project.sh
ln -s one two
ln -s three four

On the other hand if cookiecutter is changed to copy symlinks as symlinks then people who want to share template files between multiple cookiecutters will no longer have an easy solution.

@mforbes
Copy link

mforbes commented Jul 7, 2022

@seanh I agree that there should be a flag that allows the current behaviour to be maintained (probably by default), but it would be really nice if there was some way for template manager to be able to use symlinks as symlinks where they make sense. As I discuss in #865 (comment), I can almost do this now with a post-generate hook, but this requres hard-coding them in the hook (or in the template). Can someone more knowledgable comment if there might be some way to use a pre-generate hook to detect these and pass the information along to cookiecutter so they can be generated by the post-generate hook? (Or tell me if this is not easily doable because there is no way to scan the original template first if running on a platform that does not support symlinks, etc.)

An alternative might be to only preserve in-tree symlinks, but this is clever/tricky and would probably be a pain to maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This issue/PR relates to or includes documentation. please-help This issue/PR contain help request to cookiecutter users or first-time contributors
Projects
Documentation
  
Awaiting triage
Development

No branches or pull requests

5 participants