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

Shouldn't _src_path be stored as absolute path? #335

Open
ppo opened this issue Jan 30, 2021 · 6 comments
Open

Shouldn't _src_path be stored as absolute path? #335

ppo opened this issue Jan 30, 2021 · 6 comments

Comments

@ppo
Copy link

ppo commented Jan 30, 2021

When creating a project using a local path, shouldn't it be stored as absolute path in the answers_file?

If created using copier . /path/to/destination, it's saved as _src_path: ..

One can do it "auto-manually" using copier "$PWD" /path/to/destination.

@yajo
Copy link
Member

yajo commented Feb 1, 2021

That's not by design currently, but by accident. However it seems to be a good design, because if you share the project and you know that the template resides next to it in ../template, having a relative path can be helpful.

In any case, if you end up producing a copier-answers file, it means that you support updates. And the requirements for supporting updates is that your source template is a git repo with tags (otherwise there's no way to generate a smart diff, thus the update itself will be broken), so your use case is probably wrong by design anyway.

There's still the possibility that it's a local git repo. In that case, I'm still not sure what'd be better... 🤔

@ppo
Copy link
Author

ppo commented Feb 1, 2021

I guess that if you generate it from a local path, the project is not supposed to be portable/used by someone else.

If it must be portable, the template source should be an URL… otherwise it's probably only accessible by you anyway.

It could be useful to have a command to change the template source… with "use at your own risk".

BTW, is it safe to change that, just that, manually in the answers file?

@yajo
Copy link
Member

yajo commented Feb 1, 2021

BTW, is it safe to change that, just that, manually in the answers file?

I think so.

In any case, this is a real issue because even if we want relative paths, those should be relative to the project, not to the CWD.

@ppo
Copy link
Author

ppo commented Feb 2, 2021

As it's a choice, there should be an option, right?

Like --template-src="VALUE", where the value can be:

  • absolute
  • relative
  • the value to use

If that option is passed to update, Copier uses that instead of _src_path and the answers file is updated accordingly.

absolute|relative, are based on the template_src during creation and on the CWD during updates.

@lhupfeldt
Copy link

I ran into the same problem.
Storing the path relative to CWD (I got '.') is not of much use.
Storing the path as both relative to project and as absolute would be great, then the project could be moved, either independently from the template, or they could be moved together.
Adding the --template-src="VALUE" is also a good idea.
And yes, generally it is a URL (which can be a file url), så maybe the _src_path should be renamed to _src_url?

@yajo
Copy link
Member

yajo commented Aug 10, 2024

If you want it to be an absolute path, you can pass it as an absolute path, right? Why do we need extra flags for that?

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

No branches or pull requests

3 participants