-
Notifications
You must be signed in to change notification settings - Fork 76
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
rewrite #!/usr/bin/env perl #58
Comments
|
For scripts that you want to run from a git repository, what's wrong with doing I have some repositories where I split up my "scripts for aiding the development process" and "scripts I want installed into $PATH" into separate directories, and EUMM only points to one of these in EXE_FILES. Sometimes I write a wrapper script in the former directory (which might use just #!perl or #!/usr/bin/env perl) that call scripts in the latter, via |
Nothing's wrong with that, and that's orthogonal to this issue. The thing is, I can have I wish I could write |
|
👍 There are hundreds (maybe thousands) of scripts already using |
|
Personally I don't find the "but everyone is doing it" argument very compelling. |
It's not "everyone's doing it so we should do it" - it's "everyone's doing it hoping it works (without knowing it isn't supported)", and that's why the default should change to support it. |
|
👍 for rewriting! I assumed (apparently incorrectly) that using https://github.com/jberger/Galileo/blob/master/bin/galileo#L1 |
|
I've always used #!perl because I am not expecting the script to work out of the box (nor do I set an executable bit). For that matter, «#!/usr/bin/env perl» wouldn't work on non-unix operating systems anyway. |
|
I've always used #!perl because I am not expecting the script to work out #!/usr/bin/perl won't either but that gets rewritten. And env perl doesn't. — |
|
@Leont Are you arguing for the removal of |
|
+1 for @miyagawa's proposal. |
No, I'm saying the general expectation is silly and wrong. That doesn't mean that this can't be a useful feature, but I think it should be framed in a more general discussion of "what should we do if the shebang line is not targeting something that looks like a perl binary" |
|
Let me try and untangle what's going on here. First, so everyone's on the same page, MakeMaker has a feature where it will rewrite @miyagawa has noticed that fixin does not see The rub is this: Unlike all the other hard coded versions, which will not work reliably on other people's machines, As @kraith pointed out, this is a big problem. That's the issue as I see it. LMK if that summary missed anything. Proposed solution next. |
|
I do this regularly for pure perl scripts that I want bundled into I'd be happy to see an option to MakeMaker to produce the behaviour that Changing the current behaviour would be a regression from my POV. |
|
Lemme lay out my assumptions. If the assumptions aren't correct, my whole proposal doesn't work. Assumption 1, most folks who write Assumption 2, there are some people who write Assumption 2a, but most of them aren't. Assumption 3, we can't guess which is which. When you have an overwhelming majority of users doing X and a small majority wanting Y which is in conflict with X, the usual solution is to make the default X and make it configurable. Right now, fixin just happens whether you want it to or not. Here's what I propose.
The first is pretty straight forward and lets people who want all the scripts to keep their The second lets most authors continue to not care about any of this and write their The third accommodates people who have more complicated needs. I see it working like this...
I think that accommodates everyone's needs. If that's cool, I'll break this up into three issues for work. This one has gotten a bit long. |
|
@shadowcat-mst said
How a script is going to be used is a choice made not by the distribution author but by the user installing the distribution. If you can write How's that? |
|
I can see adding that to PERL_MM_OPT and being happy, yeah. Could we please, please call it SHEBANG_FIX though? That's the usual |
|
I bow to Wikipedia's authority. |
Agreed 100% on the assumptions and +1 for the proposals (SHEBANG_FIX=0 etc.). Sounds great! |
Given that that subs needs to be given in the Makefile.PL, and fixin is run through make, that may get messy… |
|
We should probably do something similar in Module::Build/Module::Build::Tiny. The former currently always rewrites, the latter does something similar to MakeMaker. |
|
I would imagine "#!/usr/bin/env perl" is used in one of the following three circumstances:
In all three cases, rewriting by default seems the correct approach. |
ExtUtils::MakeMaker rewirtes #/usr/bin/perl or #!perl but NOT #!/usr/bin/env perl, so mandatorily rewrite shebang if environment variable REWRITE_SHEBANG is set. - Perl-Toolchain-Gang/ExtUtils-MakeMaker#58
ExtUtils::MakeMaker rewirtes #/usr/bin/perl or #!perl but NOT #!/usr/bin/env perl, so mandatorily rewrite shebang if environment variable REWRITE_SHEBANG is set. - Perl-Toolchain-Gang/ExtUtils-MakeMaker#58
|
That last one is what |
- Relocatable shebangs are nice. Let's try to make them happen! - This PR is related to tickets Perl-Toolchain-Gang#38 and Perl-Toolchain-Gang#58
|
So this is merged now? Just so I'm clear, this means a distribution developer can leave |
|
No, nothing has been done yet. Even if/when it's added to EUMM, Module::Build and other installers have to be fixed, and developers still can't use |
|
Oh, OK, I mistook the purple Merged symbols for this project but they are for others. |
|
I've read this thread twice just now and I'm still not sure I understand where everyone's at so let me see if I can summarize and get some people to yell at me and tell me I'm wrong :D
It seems like the discussed solution would be to:
Right now everyone's unhappy. Some CPAN distros rewrite to Is anyone actually against this proposed fix? |
|
SHEBANG_FIX refers to the behavior that it already currently does, so the name should be different, but otherwise 👍 |
That solution is mostly what was suggested at the top of the thread; most of the following conversation is not reflected. It does reflect some of the discussion in that it includes a way to change the rewritten value to something other than
I am. I am actually in favour of each one of the points in the proposal, but I am against the proposal as a whole, because it is incomplete. I imagine everyone else on the thread so far who voiced concerns about breakage feels the same way. |
Many of the comments above were answered and this ticketing system doesn't really allow for threading so it's not clear what's "unanswered". Could you please be clear what additional change / improvement would be needed? |
Sorry, I missed this part of your reply. It's my opinion that the decision on what the shebang is should be in the power of the person installing the script, not the CPAN author. In most if not all cases, the CPAN author doesn't actually know what every person doing the install wants. So my question to you: Under what circumstances would the user or distro maintainer actually benefit from some of the shebangs in a distro being If you come up with one, is there any reason the distro maintainer couldn't just patch that in their edge case? We're already planning to provide a command line option to specify the shebang in every module install. |
|
What about support for an environment variable which tells the fixins the installer wants |
|
The vast majority of installers will not know they want this - shebang fix needs to "just work", but certainly there should be a way to skip rewriting, though my uninformed opinion is there should be an option to rewrite all shebangs to |
|
The big "But what about" seems to be relocatable perl. That's a |
I agree but this ticket doesn't seem to be going anywhere so I'm looking for a compromise. Perhaps cpan.pm could set the environment var, etc and we could move forward. |
(Somewhat related to #37 and #38?)
Is there any reason that ExtUtils::MakeMaker fixin() rewrites
#!/usr/bin/perlor#!perlbut NOT#!/usr/bin/env perl?There are many reasons
#!/usr/bin/env perldo not work when installed. Keeping that line in the shebang sounds wrong to me.Yet, having
#!/usr/bin/env perlis useful for scripts that you want to run from a git repository etc. Look what I do with cpanm bin scripts so that you can run from a git repo by cp, but also installable to the right perl path, by rewriting the shebang in Makefile.PL: https://github.com/miyagawa/cpanminus/blob/devel/Makefile.PL#L9There might be a valid use case for allowing
#!/usr/bin/env perlas stated in #38 - so it might make sense to "allow" it by leaving as is if@INCis configured as relocatable, but by default, it makes more sense to rewrite it upon install, the same way it does with#!perl.The text was updated successfully, but these errors were encountered: