Template2 icon indicating copy to clipboard operation
Template2 copied to clipboard

Template Fails When Using Windows Paths Under Cygwin

Open jrmash opened this issue 8 years ago • 4 comments

Using the Template module under Cygwin with standard Windows style paths (C:/Dir/File.tt), it bombs out with the following error:

  • file error - no providers for template prefix 'C'

This is (arguably) valid syntax and it seems that this particular scenario is not caught in Template::Context, but I will defer to you as the domain expert on what the proper fix should be. This was verified using Template v2.26 on perl 5.14, 5.20, and 5.22 across a couple variants of Windows.

Feel free to hit me up if you need a tester for verification.

jrmash avatar Apr 15 '16 06:04 jrmash

@jrmash What is your current method of referencing File.tt? do you need to reference alternate drives or is it always on the same local drive? (we could strip off C: easily.)

toddr avatar Oct 05 '18 18:10 toddr

As memory serves, the script in question was a local one-off that was not intended for public consumption, so it was easy enough for me to just run it in a standard Windows shell as a workaround.

I am not too familiar with all the inner workings of Template Toolkit, but I would be concerned about just removing the drive designation from the path, if only because the path ("/Dir/File.tt") doesn't generally mean the same thing in Cygwin and Windows shells.

jrmash avatar Oct 06 '18 03:10 jrmash

Ok. Right now I'll be honest we're trying to stabilize travis and fix some of the bugs that have supplied patches. We're not going to get to this right away.

The thing we're not familiar with is the inner workings of Windows Perl so things like how E:\ works in perl is somewhat of a mystery for me.

All of this is to say that short of a provided patch, it's going to be a while before we get to this.

Thanks for replying!

toddr avatar Oct 06 '18 03:10 toddr

The core of this issue seems to be that the Windows specific logic to split INCLUDE_PATH is not applied under Cygwin (independently of the fact that that logic is currently broken by #158). However, I don’t think that there is a good fix for this, because just applying the windows splitting logic on Cygwin would mean that it’s no longer possible to pass multiple Unix style absolute paths (as a colon is always followed by a slash in that case) while Cygwin is meant to support both path styles.

Meanwhile, there are some simple workarounds, either passing INCLUDE_PATH as an array-ref or passing a custom DELIMITER.

I guess part of the problem here is that, even with these simple workaround, it’s difficult to understand the cause of the issue when it strikes (in the example here there is a hint when the provider for template prefix 'C' is not found (but it was not the case in #158). So, possibly, if the splitting always had to be requested manually by the caller (or even done on the caller side), this might be better from an API point of view (given how easy it is to split paths anyway). But it might be difficult to change that now.

mkende avatar Apr 11 '24 11:04 mkende