Reputation: 59
I got a huge project written on Perl, which contains many of scripts which starts with typical #!/usr/bin/perl
For this project I need a custom-built Perl to be compiled from source.
I tried just to replace /usr/bin/perl with my compiled one but OS becomes broken (for ex. module version mismatch etc).
So is there any correct way to replace system perl with my own-built one or the easiest way would be to edit all tons of scripts and replace /usr/bin/perl with /usr/local/bin/perl or something like this?
Upvotes: 2
Views: 1489
Reputation: 59
According to comments, there is no solution to replace system Perl without of destroying something but the're 3 solutions to solve the descibed problem. For all of them i need to modify all the scripts.
Special thanks to @Joshua and @ikegami
Upvotes: 2
Reputation: 2317
Do not replace system perl (or system binaries in general). You can build it to another location (as you suggested, /usr/local
for example) and call it manually.
My personal preference is to use plenv. There's a nice guide here to get you started.
If you admin the server and other users are logging in an using your scripts, you'll want to build plenv somewhere outside your home directory (eg. /opt/plenv
) and ensure that all users $PATH is prepended with the bin path of your new perl. Without digressing too much, this can be done in /etc/profile
or even better to declare you custom profile mods in a custom profile script (eg. /etc/profile.d/custom.sh
).
I would also suggest using a more portable shebang such as (This is a personal preference based entirely how I admin my boxes and probably not a good idea to recommend unless you know the full repercussions. Administering a server is entirely subjective based on it's use-case, your use-case likely differs vastly from mine).#!/usr/bin/env perl
which will use whichever perl is in a users $PATH
first. The only exception to this is cron jobs, which I typically always hardcode full paths.
Upvotes: 5