2023-06-17
It sizzled and fizzled, until the fire rekindled.
$
Hello World! moment with Perl on Mac using IntelliJ IDEA (Ultimate) debugger
#Mac
#project/learn-by-doing
#project/started
Read till the end. Lesson learned: Efforts do pay off in the end.
Install IntelliJ IDEA
Searching for a good GUI debugger for Perl on Mac. No joy for a few days until I stumbled on this video. It demos the Windows version of IntelliJ IDEA, but luckily I knew this IDE long ago, so I quickly verified that it has a Mac version as well. I thought, what the heck, I should give it a try. One thing led to another. Soon I have already installed the JetBrains IntelliJ IDEA Ultimate version using my school credential from De Anza. Yay!
Install the Perl5 plugin
Done, thanks to the handholding of the video.
Create a Perl5 project
These days one cannot simply write a Perl script and run. You have to have a ... project! Just shoot me.
Locate the Perl interpreter
Not too hard. UI gives the option of browsing to the system Perl, so I found it here, thanks to my dinosaur memory of this "Unix" command:
ekliao@ELI-1T-Side-MBP14 ~ % which perl
/usr/bin/perl
``
Add Perl script file
Under the project, right-click and "new Perl5 file." This is going to be a motif.
Add code
IntelliJ promotes best practices, so the "pragmas" below are supplied by default. Spiffy!
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
I simply added the obligatory print "Hello world on Mac!";
line.
Run the script
Easy enough. From the menu: "Run {script-name}" or CTRL-R
.
Debug the script
Hit the first snag. Couldn't debug without a certain Perl module. IntelliJ prompted (bottom right) to install it. I said yes, but it exited with an error. Ah shuck! Another option suggested was installing from CPAN. Tried it too. Still resulted in error.
The same video guided me to do this: Open command line, install Camelcadedb
:
ekliao@ELI-1T-Side-MBP14 ~ % cpan Devel::Camelcadedb
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/Users/ekliao/.cpan/Metadata'
Database was generated on Sun, 18 Jun 2023 17:17:01 GMT
Running install for module 'Devel::Camelcadedb'
Checksum for /Users/ekliao/.cpan/sources/authors/id/H/HU/HURRICUP/Devel-Camelcadedb-v2023.1.tar.gz ok
Configuring H/HU/HURRICUP/Devel-Camelcadedb-v2023.1.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
......
Installing /Users/ekliao/perl5/lib/perl5/Devel/Camelcadedb.pod
Installing /Users/ekliao/perl5/lib/perl5/Devel/Camelcadedb.pm
Installing /Users/ekliao/perl5/man/man3/Devel::Camelcadedb.3pm
Appending installation info to /Users/ekliao/perl5/lib/perl5/darwin-thread-multi-2level/perllocal.pod
HURRICUP/Devel-Camelcadedb-v2023.1.tar.gz
/usr/bin/make install -- OK
Sweet! Despite this success, IDEA still reported missing packages.
Showstopper problem with IntelliJ IDEA for Perl on Mac
One serious problem is, in settings, the external Perl libraries cannot be browsed to and added due to Finder making it a hidden/system path!
Result: Stuck. Aborted.
Another user reported a related problem. Here's my take:
(325) Installing Perl with Debugger in Intellij IDEA - YouTube
Metadata
- Title: (325) Installing Perl with Debugger in Intellij IDEA - YouTube
- Tags: #IntelliJ-IDEA-Mac, #Perl, #Mac
- URL: https://www.youtube.com/watch?v=fs4EdJikN2c
Highlights & Notes
- Not useful if you are on a Mac and don't know where the perl libraries are.
Page Comment
I know where the Perl libraries are, but a deadly IDEA (on Mac) problem is, in settings, the external Perl libraries cannot be browsed to and added due to Finder making it a hidden/system path! Sadly, this makes IDEA unusable for debugging Perl.
Update on the earlier failed attempt
2023-06-17 Turns out, the trick to browse to the hidden library is to do OPTION-SHIFT-.
while in an open Finder window (having clicked on the + from IDE to add the path). The Finder window will toggle to reveal all hidden directories.
!500
Having added the path to perl5 libraries, the debugger proceeded to debug fine.
Update for Windows: fail
#project/started
2023-06-17 The same attempt for debugging on Windows using IntelliJ IDEA also failed, but for a different reason: Unable to use gmake (refused to use dmake) while installing CPAN packages necessary for debugging.
#project/aborted