a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

I’d kill a man to get Perl in a-Shell

Open gruber opened this issue 3 years ago • 19 comments

Just kidding. (Not kidding.)

Is there a technical reason Perl isn’t included?

gruber avatar Apr 17 '21 02:04 gruber

I would really like to have Perl too (mainly because a lot of TeX commands use it). The technical reason is: it's really difficult to cross-compile. Perl uses its own script to guess compilation options, and that script is not designed for cross-compilation. I've been trying regularly, and I keep trying. I'll succeed eventually.

holzschu avatar Apr 17 '21 06:04 holzschu

Okay, I've got good news and I've got bad news.

The good news: perl is sort of working right now (there's still a bit to polish before release, but I have passed the big blocking point). So your body count should remain at its current value, and Perl should become available in the near future.

The bad news: it's going to be a static build. For many reasons, but mainly because dynamic modules have to be signed by the App developer, so they have to be built beforehand, and I have to rewrite the dynamic library loading mechanism because the libraries aren't when perl thinks they are so...

Which brings me to a question: which Perl extensions or modules should absolutely be included in the default version?

holzschu avatar May 03 '21 15:05 holzschu

Does this mean you won’t be able to install any modules from CPAN? Or just compiled libraries from CPAN? I have a few modules I’d like from CPAN but I’m not sure where to suggest drawing the line beyond the standard library. (Am I misunderstanding what this “static build” issue means?)

gruber avatar May 03 '21 16:05 gruber

I think we will be able to install all pure Perl modules from CPAN (that's the goal), but any module that requires compiling will be impossible. That's the same deal as Python, basically.

The difference between "static build" and "standard build" is that all the extensions (even those from the standard library) are included in the Perl binary. That makes a larger binary, but at 11 MB I think it's OK.

holzschu avatar May 03 '21 18:05 holzschu

Sounds like exactly what I was hoping for (pure Perl modules being installable, compiled ones not). 11 MB does not seem too big nowadays.

gruber avatar May 04 '21 00:05 gruber

This would be amazing to see. For many years I’ve wanted to run exiftool on my iPad to geotag my RAW photos using a gpx file. Adding Perl to a-shell would make this possible.

Thank you for continuing to make a great app even better.

emkayonline avatar May 10 '21 16:05 emkayonline

We're making progress: the latest TestFlight build has Perl: https://testflight.apple.com/join/WUdKe3f4

And it can even run Perl scripts, including cpan. Except it cannot install modules that use a C compiler (obviously) or modules that call the command "make" as part of the install process. Which is basically everything. So it can run cpan, but cpan cannot install anything.

I'm working on make now, so eventually cpan will be functioning. In the meantime, please test Perl and report issues.

holzschu avatar May 18 '21 21:05 holzschu

We're making progress: the latest TestFlight build has Perl: https://testflight.apple.com/join/WUdKe3f4

@holzschu @emkayonline @gruber This TestFlight build really helps. Thanks @holzschu .

aramb-dev avatar May 18 '21 21:05 aramb-dev

After a (non-exhaustive) test I have exiftool running in a-shell. I installed it from a tar bundle rather than CPAN, but it seems to be working great. Thanks.

emkayonline avatar May 19 '21 08:05 emkayonline

A wee bit of tire-kicking and it definitely works, and for me will be useful right out of the box without CPAN/make.

One thing I noticed though is that perldoc isn’t installed. Is that a deliberate choice?

Also: is this new jsi command something you created? I’ve wondered for years why there are no JavaScript command-line interpreters for writing shell scripts.

gruber avatar May 19 '21 18:05 gruber

jsi is the work of @personalizedrefrigerator, see #149, #207, #211, #212.

I did install perldoc (the binary), but I missed quite a lot of .pod files (including perldoc.pod). That will be fixed in the next TestFlight release.

I now have make, and as a result cpan Package runs till the end... but it does not appear to have installed anything anywhere. I plan to fix that before the next TestFlight.

holzschu avatar May 19 '21 19:05 holzschu

A new TestFlight version is available (same place): https://testflight.apple.com/join/WUdKe3f4 This time, cpan works (at least it works on all the packages I have tried). fork does not work with unmodified Perl scripts (you have to edit them a bit to run through both branches), so testing is disabled by default (CPAN_OPTS=-T) (because many testing scripts use fork).

Perl has been on the TODO list since the beginning of iOS_system. That'll be one huge checkmark.

holzschu avatar May 23 '21 06:05 holzschu

This is really nice, with pip and cpan theres a wealth of tools available.

However cpan still blows up with Too many Perl scripts on many installs. E.g. cpan -Ti App::Music::ChordPro doesn't work. I guess this is because some build scripts start nested perl processes.

normen avatar Jan 18 '22 19:01 normen

There are two possibilities for cpan to fail:

  • because the package contains dynamic libraries. Without a compiler, we can't do much here.
  • because cpan runs too many nested perl process. Splitting the install job into sub-jobs can help.

I could increase the number of perl binaries present (for now, it's limited to two).

holzschu avatar Jan 18 '22 20:01 holzschu

Might be a cat and mouse game but I guess at least three are in order given that cpan often runs Makefile.PL which in turn might run some perl tool..?

normen avatar Jan 18 '22 21:01 normen

Heh, indeed, most installs fail when the Makefile.PL checks for a valid perl.. Which would then be the third instance cpan->Makefile.PL->perl -V

Edit: Manually compiling the artifacts in ~/Documents/.cpan/build/* like this works, its a bit tedious though 😬

perl Makefile.PL
make install

normen avatar Jan 18 '22 21:01 normen

cpan doesn’t seem to work for me, even for what I think are pure-Perl modules. E.g. cpan YAML. (I think the YAML module should be included by default, BTW.)

What happens is, cpan seems to run well until it gets to the end, when it attempts to run the actual Makefile.pl, and then a-Shell just hangs. It seems to be doing something at that step, because my iPhone got warm, but it never finishes. And killing the process with Control-D leaves a-Shell in a bad state where nothing actually executes at the prompt until you force quit the whole app.

Is cpan currently working as intended? If so, what’s an example module that actually can be installed?

gruber avatar May 01 '22 00:05 gruber

I've fixed a bug with Perl recently. I'll check if it fixes the issue with CPAN.

holzschu avatar May 01 '22 06:05 holzschu

The bad news is, it did not fix the issue with CPAN. The good news is, now I think I have fixed it. CPAN YAML works, at least. Tests are disabled, as before, but at a deeper level (inside CPAN.pm, rather than using CPAN_OPTS) to avoid issues.

App::Music::ChordPro still fails, but (as far as I can tell) it's because it depends on Alien::Build, which requires a C compiler.

holzschu avatar May 10 '22 14:05 holzschu