Homebrew-core: Using perl's local::lib does not work as stated in caveat

Created on 7 May 2017  路  6Comments  路  Source: Homebrew/homebrew-core

Please always follow these steps:

  • [x] Confirmed this is a problem with only one, specific formula and not Homebrew/brew? If it's a general Homebrew/brew problem please file this issue at https://github.com/Homebrew/brew/issues/new
  • [x] Ran brew update and retried your prior step?
  • [x] Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • [x] Ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
$ brew gist-logs perl
Error: No logs.
  • [x] If brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?
$ brew config
HOMEBREW_VERSION: 1.2.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 8cba0352e0be94263e2ed96c98bf93d8f2fce8ef
Last commit: 6 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 9c4f788f512c3fdb9f83dace59b2194a778c13bd
Core tap last commit: 8 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit ivybridge
Homebrew Ruby: 2.0.0-p648
Clang: 8.1 build 802
Git: 2.12.2 => /usr/local/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.24.1/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.4.1_1/bin/ruby
Java: 1.8.0_131
macOS: 10.12.4-x86_64
Xcode: 8.3.2
CLT: 8.3.2.0.1.1492020469
X11: 2.7.11 => /opt/X11
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  docker

Hi!

While trying to solve #12870 I encountered the issue that using local::lib does not work unless you manually sudo chown -R <username> ~/perl5.

In more detail:
The caveat for perl states:

$ brew info perl
perl: stable 5.24.1 (bottled), HEAD
<snip>
==> Caveats
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

Running

PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib

produced a whole lot of output and prompts for the password to do a final sudo /usr/bin/make install. It did exit successfully and created ~/perl5 containing two folders man and lib.

Running the second command which adds

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

to my ~/.bash_profile works too, but leads to the following error when sourcing ~/.bash_profile:

$ source .bash_profile
Attempting to create directory /Users/iokill/perl5
Unable to create /Users/iokill/perl5/bin: No such file or directory at /Users/iokill/perl5/lib/perl5/local/lib.pm line 686.
BEGIN failed--compilation aborted.

A bit of digging showed, that ~/perl5 is owned by root, so this command fails because it cannot create ~/perl5/bin when run as non-root user.
A manual sudo chown -R iokill ~/perl5/ seemed to do the trick however and also allows me to do cpan <module> as non-root.

It looks to me like this is something that should be mentioned in the caveat.

All 6 comments

Good catch! Even better could be to figure out how to call cpan without requiring sudo.

Normally, doing this should not, and does not, require the use of sudo. There is very likely something external causing this, perhaps permissions/ownership related. Since cpan is normally owned and run by the user, it should be able to install to $HOME and create the ~/perl5 directory and its subdirs without issue. I think assuming the caveat to be incorrect at this point is a tad hasty.

@iokill Would you mind checking the permissions and ownership of both your Homebrew installation, especially perl/cpan, as well as your home directory, including those of the directory itself?

There is seemingly nothing, either in running cpan local::lib or creating the required directories, that should require elevated privileges under normal circumstances.

Can you provide a full reproduction here? I've ran this through a whole bunch of times without hitting it.

Loading internal null logger. Install Log::Log4perl for logging messages
Reading '/Users/xyz/.cpan/Metadata'
  Database was generated on Sat, 06 May 2017 14:53:58 GMT
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/Users/xyz/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with HTTP::Tiny:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/Users/xyz/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Thu, 11 May 2017 00:54:00 GMT
  HTTP::Date not available
.............
  New CPAN.pm version (v2.16) available.
  [Currently running version is v2.1101]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.


...............................................................DONE
Fetching with HTTP::Tiny:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/Users/xyz/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /Users/xyz/.cpan/Metadata
Running install for module 'local::lib'
Checksum for /Users/xyz/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000019.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring H/HA/HAARG/local-lib-2.000019.tar.gz with Makefile.PL

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for local::lib
Writing MYMETA.yml and MYMETA.json
  HAARG/local-lib-2.000019.tar.gz
  /usr/local/Cellar/perl/5.24.1/bin/perl Makefile.PL -- OK
Running make for H/HA/HAARG/local-lib-2.000019.tar.gz
cp lib/lib/core/only.pm blib/lib/lib/core/only.pm
cp lib/local/lib.pm blib/lib/local/lib.pm
cp lib/POD2/PT_BR/local/lib.pod blib/lib/POD2/PT_BR/local/lib.pod
cp lib/POD2/DE/local/lib.pod blib/lib/POD2/DE/local/lib.pod
Manifying 4 pod documents
  HAARG/local-lib-2.000019.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/local/Cellar/perl/5.24.1/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/bad_variables.t ...... ok
t/carp-mismatch.t ...... ok
t/classmethod.t ........ ok
t/coderefs_in_inc.t .... ok
t/de-dup.t ............. ok
t/lib-core-only.t ...... ok
t/pipeline.t ........... ok
t/shell.t .............. ok
t/stackable.t .......... ok
t/subroutine-in-inc.t .. ok
t/taint-mode.t ......... ok
All tests successful.
Files=11, Tests=221,  3 wallclock secs ( 0.06 usr  0.03 sys +  2.21 cusr  0.88 csys =  3.18 CPU)
Result: PASS
  HAARG/local-lib-2.000019.tar.gz
  /usr/bin/make test -- OK
Running make install
Manifying 4 pod documents
Installing /Users/xyz/perl5/lib/perl5/lib/core/only.pm
Installing /Users/xyz/perl5/lib/perl5/local/lib.pm
Installing /Users/xyz/perl5/lib/perl5/POD2/DE/local/lib.pod
Installing /Users/xyz/perl5/lib/perl5/POD2/PT_BR/local/lib.pod
Installing /Users/xyz/perl5/man/man3/lib::core::only.3
Installing /Users/xyz/perl5/man/man3/local::lib.3
Installing /Users/xyz/perl5/man/man3/POD2::DE::local::lib.3
Installing /Users/xyz/perl5/man/man3/POD2::PT_BR::local::lib.3
Appending installation info to /Users/xyz/perl5/lib/perl5/darwin-thread-multi-2level/perllocal.pod
  HAARG/local-lib-2.000019.tar.gz
  /usr/bin/make install  -- OK

Apologies, I left my comment without refreshing first & didn't realise @JCount had made it perfectly redundant 馃槃.

@DomT4 @JCount @dunn I'm sorry! Looks like i messed that up 馃槙

I just did a fresh install of perl and it works as expected without requiring sudo for PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib. Consequently, everything works as stated in the caveat then.

I was sure I did a fresh install before reporting this, but it turns out that I must have missed that somehow.

Thanks!

No worries, thanks for letting us know. Given I wrote most of the perl formula colour me relieved you didn't find breakage 馃樃.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tejasmanohar picture tejasmanohar  路  3Comments

dredmorbius picture dredmorbius  路  3Comments

daviderestivo picture daviderestivo  路  4Comments

ghostbar picture ghostbar  路  4Comments

jakepetroules picture jakepetroules  路  3Comments