6

Before I begin, I should note that I never had this problem on macOS 10.15 Catalina, and the responses in this similar thread did not solve the problem, unfortunately.

I'm experimenting with latexindent on a fresh install of macOS 11 Big Sur and I'm having issues with File:HomeDir: running latexindent returns a whole list of errors, beginning with Can't locate File/HomeDir.pm in @INC. I've tried using cpan to install that module, but I end up with following:

Reading '/Users/myname/.cpan/Metadata'
  Database was generated on Thu, 24 Dec 2020 05:41:03 GMT
Running install for module 'File::HomeDir'
Checksum for /Users/myname/.cpan/sources/authors/id/R/RE/REHSACK/File-HomeDir-1.006.tar.gz ok
Scanning cache /Users/myname/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring R/RE/REHSACK/File-HomeDir-1.006.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Mac::SystemDirectory 0.04 not found.
Generating a Unix-style Makefile
Writing Makefile for File::HomeDir
Writing MYMETA.yml and MYMETA.json
  REHSACK/File-HomeDir-1.006.tar.gz
  /usr/bin/perl Makefile.PL -- OK
Running make for R/RE/REHSACK/File-HomeDir-1.006.tar.gz
---- Unsatisfied dependencies detected during ----
----     REHSACK/File-HomeDir-1.006.tar.gz    ----
    Mac::SystemDirectory [requires]
Running install for module 'Mac::SystemDirectory'
Checksum for /Users/myname/.cpan/sources/authors/id/E/ET/ETHER/Mac-SystemDirectory-0.13.tar.gz ok
Configuring E/ET/ETHER/Mac-SystemDirectory-0.13.tar.gz with Makefile.PL
HASCOMPILERjIOx/TESTn6oE.c:2:10: fatal error: 'EXTERN.h' file not found
#include "EXTERN.h"
         ^~~~~~~~~~
1 error generated.
Couldn't execute cc  -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -Os "-I/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE"   -c HASCOMPILERjIOx/TESTn6oE.c -o HASCOMPILERjIOx/TESTn6oE.o: Inappropriate ioctl for device at Makefile.PL line 14.
Requires a compiler
Warning: No success on command[/usr/bin/perl Makefile.PL]
  ETHER/Mac-SystemDirectory-0.13.tar.gz
  /usr/bin/perl Makefile.PL -- NOT OK
  REHSACK/File-HomeDir-1.006.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/File-HomeDir-1.006-2
  REHSACK/File-HomeDir-1.006.tar.gz
  Has already been prepared
Running make for R/RE/REHSACK/File-HomeDir-1.006.tar.gz
Warning: Prerequisite 'Mac::SystemDirectory => 0.04' for 'REHSACK/File-HomeDir-1.006.tar.gz' failed when processing 'ETHER/Mac-SystemDirectory-0.13.tar.gz' with 'writemakefile => NO '/usr/bin/perl Makefile.PL' returned status 6400'. Continuing, but chances to succeed are limited.
cp lib/File/HomeDir/Driver.pm blib/lib/File/HomeDir/Driver.pm
cp lib/File/HomeDir/MacOS9.pm blib/lib/File/HomeDir/MacOS9.pm
cp lib/File/HomeDir/Darwin/Carbon.pm blib/lib/File/HomeDir/Darwin/Carbon.pm
cp lib/File/HomeDir/Darwin/Cocoa.pm blib/lib/File/HomeDir/Darwin/Cocoa.pm
cp lib/File/HomeDir/Windows.pm blib/lib/File/HomeDir/Windows.pm
cp lib/File/HomeDir/FreeDesktop.pm blib/lib/File/HomeDir/FreeDesktop.pm
cp lib/File/HomeDir.pm blib/lib/File/HomeDir.pm
cp lib/File/HomeDir/Test.pm blib/lib/File/HomeDir/Test.pm
cp lib/File/HomeDir/Darwin.pm blib/lib/File/HomeDir/Darwin.pm
cp lib/File/HomeDir/Unix.pm blib/lib/File/HomeDir/Unix.pm
Manifying 10 pod documents
  REHSACK/File-HomeDir-1.006.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t xt/*.t
t/01_compile.t ........ 1/11 # Implemented by: File::HomeDir::Darwin
t/01_compile.t ........ ok     
t/02_main.t ........... # $<: 501 -- $(: 20 20 12 61 79 80 81 98 701 33 100 204 250 395 398 399 400
t/02_main.t ........... ok     
t/10_test.t ........... ok     
t/11_darwin.t ......... ok   
t/12_darwin_carbon.t .. skipped: Not running on 32-bit Darwin
t/13_darwin_cocoa.t ... skipped: Not running on Darwin with Cocoa API using Mac::SystemDirectory
t/20_empty_home.t ..... ok   
All tests successful.
Files=7, Tests=90,  1 wallclock secs ( 0.04 usr  0.01 sys +  0.48 cusr  0.13 csys =  0.66 CPU)
Result: PASS
  REHSACK/File-HomeDir-1.006.tar.gz
Tests succeeded but one dependency not OK (Mac::SystemDirectory)
  REHSACK/File-HomeDir-1.006.tar.gz
  [dependencies] -- NA
Failed during this command:
 ETHER/Mac-SystemDirectory-0.13.tar.gz        : writemakefile NO '/usr/bin/perl Makefile.PL' returned status 6400
 REHSACK/File-HomeDir-1.006.tar.gz            : make_test NO one dependency not OK (Mac::SystemDirectory)

I really don't know much about perl, but it seems to me that Mac::SystemDirectory is missing, When I try to install that, however, I get

Reading '/Users/myname/.cpan/Metadata'
  Database was generated on Thu, 24 Dec 2020 05:41:03 GMT
Running install for module 'Mac::SystemDirectory'
Checksum for /Users/myname/.cpan/sources/authors/id/E/ET/ETHER/Mac-SystemDirectory-0.13.tar.gz ok
Scanning cache /Users/myname/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring E/ET/ETHER/Mac-SystemDirectory-0.13.tar.gz with Makefile.PL
HASCOMPILER5Emh/TESTS3W7.c:2:10: fatal error: 'EXTERN.h' file not found
#include "EXTERN.h"
         ^~~~~~~~~~
1 error generated.
Couldn't execute cc  -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -Os "-I/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE"   -c HASCOMPILER5Emh/TESTS3W7.c -o HASCOMPILER5Emh/TESTS3W7.o: Inappropriate ioctl for device at Makefile.PL line 14.
Requires a compiler
Warning: No success on command[/usr/bin/perl Makefile.PL]
  ETHER/Mac-SystemDirectory-0.13.tar.gz
  /usr/bin/perl Makefile.PL -- NOT OK
Failed during this command:
 ETHER/Mac-SystemDirectory-0.13.tar.gz        : writemakefile NO '/usr/bin/perl Makefile.PL' returned status 6400

From this it seems that a header file EXTERN.h is missing, but I'm not sure where to go from here. Does anyone have any thoughts or suggestions? My apologies for the huge blocks of code - I figured it would be better to include all possible details. Thanks a lot!

Note: I posted this same question in the LaTeX Stack Exchange, but figured I would also ask here since it seems to be a broader perl issue.

8
  • EXTERN.h is part of Perl. But your distro (Apple) might have withheld its inclusion. Maybe there's a package you need to install?
    – ikegami
    Commented Dec 24, 2020 at 8:07
  • There are problems building modules that try to link to external libraries right now on Big Sur, but this doesn't seem related.
    – ikegami
    Commented Dec 24, 2020 at 8:10
  • 1
    Which version of perl are you using? Type which perl; perl --version. If you are using the system perl, maybe you could try install perl 5.32 using perlbrew? I think then you will get the EXTERN.h header Commented Dec 24, 2020 at 8:46
  • 1
    Seems like it is ExtUtils::HasCompiler that fails, I have added an issue at their issue tracker Commented Dec 24, 2020 at 9:49
  • 3
    A temporary fix seems to be to set the include search path explicitly: export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE:$CPATH and then run sudo cpan Mac::SystemDirectory Commented Dec 24, 2020 at 11:00

1 Answer 1

8

To summarize the solution that worked for me: the issue is the header file EXTERN.h isn't on the CPATH by default in macOS 11 Big Sur. To fix this, add the directory containing EXTERN.h to CPATH:

export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE:$CPATH

Then open the cpan shell (just type cpan then enter into the command line) and type install Mac::SystemDirectory. After this process finished I was able to install File:HomeDir as well, and some other modules, to get latexindent working.

Note: I had to set up cpan before I did this; just opening the shell and following the instructions was sufficient.

Thanks a lot to Håkon Hægland for the solution!

4
  • 1
    For me, the path /Library/Developer/CommandLineTools/SDKs/ doesn't exist (the only directory inside CommandLineTools is usr/share/man). I don't know where to go from there. I tried brew install perl but it did not create that directory. My perl --version is v5.28.2.
    – jarhill0
    Commented Feb 4, 2021 at 2:28
  • 2
    Have you run xcode-select --install? I think that should populate the CommandLineTools directory. Commented Feb 5, 2021 at 3:31
  • 1
    Perfect, thank you very much! I think this got me past this particular issue.
    – jarhill0
    Commented Feb 6, 2021 at 0:38
  • If the current $CPATH is empty, then this solution will add . to the default include paths. This can cause issues elsewhere, such as VSCode's C++ extension. The version in this answer is also no longer included in the latest version of macOS. An updated and fixed version would be export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE${CPATH:+:${CPATH}}" Commented Mar 24, 2022 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.