How to trim URL to root domain?

  1. In the Finder go to your Home directory (⇧⌘H)
  2. Show the invisible files with .

No, as said "in KM". See also this KM Wiki article.

  1. Open KM Editor's Preferences (⌘,)

  2. Go to Variables

  3. If the variables are already there, then edit them. If not, then create them by clicking the + button at the bottom of the window.

So, no Terminal needed for that.

No, I do not have either.
How do I create them, and what is their content?

Can I use ~ instead of /users/<MyUserName> ?
~/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

Well, this is weird. I’m on a relatively new Mac myself and I didn’t have to create them. And as far as I remember I never created them.

But a quick search on the Web shows that it is not uncommon that they are missing.

So just create the .bash_profile:

touch ~/.bash_profile

No, this won't work. But you don't need the first one, since probably you don't have a bin directory in your Home folder.

The important part, if you are using Homebrew, is the /usr/local/bin. It should be before the /usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin or whatever you have there.

Separate the paths with a :

To check if KM knows the path execute this action in KM (assuming you have already installed Homebrew on that Mac):

It should give you this:

brew is /usr/local/bin/brew

If you see something like this

/var/folders/wn/28w_v3513m50gcc9qtvg3bfh0000gn/T/Keyboard-Maestro-Script-C3F0A491-02A6-491C-81D6-0A8D6467661B: line 1: type: brew: not found

then your ENV_PATH is not correct.

OK, here is how I translate that into specific commands.
Please review and confirm/correct.

# Is brew installed as part of the macOS?

# Create bash_profile if it does not exit
touch ~/.bash_profile

# INSTALL PERL if not already installed
# use this rather than the perl that comes with macOS
# How can we check to see if it is already installed?
brew install perl

# INSTALL cpan
brew install cpanm

# INSTALL Required Modules
cpanm Domain::PublicSuffix
cpanm Net::Domain::ExpireDate
cpanm Date::Calc

# SET KM VARIABLES
ENV_PATH: /usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 
ENV_PERL5LIB: /usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0

Nope. Your KM variables are missing exactly the most important parts:

ENV_PATH: /usr/local/bin (before the others, separated by a :). See here.

ENV_PERL5LIB: /Users/jimunderwood/perl5/lib/perl5 (also before the others). See here.

The rest seems correct. But do not blindly execute all in a row. Keep an eye on the messages and follow them! In case of doubt: ask.

OK, here’s my revised instructions:

# Is brew installed as part of the macOS?

# Create bash_profile if it does not exit
touch ~/.bash_profile

# INSTALL PERL if not already installed
# use this rather than the perl that comes with macOS
# How can we check to see if it is already installed?
brew install perl

# INSTALL cpan
brew install cpanm

# INSTALL Required Modules
cpanm Domain::PublicSuffix
cpanm Net::Domain::ExpireDate
cpanm Date::Calc

# SET KM VARIABLES (Rev 1)
ENV_PATH: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 
ENV_PERL5LIB: /Users/<MacUserName>/perl5/lib/perl5:/usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0

Questions:

  1. Is brew installed as part of the macOS?
  2. How can we check to see if perl is already installed?

Seems fine. Give it a try :wink:

No. See here how to install it. BTW, I do not want to force you to use Homebrew. There are other package managers, like MacPorts. So feel free to use whichever you want.

perl is installed on every macOS, as well as ruby and python etc. But if you are using a scripting language regularly I wouldn't meddle too much with the ones installed by default, because these are going to be used by other programs and maybe even the system itself. In addition the preinstalled versions are rarely up-to-date.

With

type -a perl

you can see all installed perl versions.

I have no preference, or knowledge about package managers.
If you like Homebrew then that's good enough for me. :wink:

Thanks again for your help.

If you are going to use HB it has the advantage that I'm able to help you. MacPorts may install perl differently, I don't know.

1 Like

There is a slight error in your to-do list:

# INSTALL cpan
brew install cpanm

cpancpanm

  • cpan is the “normal” CPAN package (module) manager. It can be a bit difficult to handle.
  • cpanm (aka cpanminus) is an alternate (but well established) package manager. It is less difficult to handle, IMO.
  • CPAN (uppercase) is the module archive itself.

this creates an EMPTY file???

What should be in it?

Leave it empty.
When installing perl via HB (and following the instruction messages in the Terminal) you should find this in .bash_profile:

eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

See here for an explanation of local::lib.

Without that the modules will end up in /usr/local/Cellar/perl/5.26.0…, which has the disadvantage that you have to reinstall every module after each perl update.

After I installed perl, I got this:

By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.

You can set that up like this:
  PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile

Should I do that?

Yep, the message is describing exactly what I have said in the last post. So, please, do it! :slight_smile:

Check your .bash_profile afterwards for that line. (Before installing cpanm.) and check also the env variables by executing this

env | grep 'perl'

Post the output here.