简体   繁体   English

如何在 Mac OS X Mavericks 上降级 Perl

[英]How to downgrade Perl on Mac OS X Mavericks

The newly release Mavericks has removed the deprecated module "Switch.pm" from its repository.新发布的 Mavericks 已从其存储库中删除了已弃用的模块“Switch.pm”。 However, I have recently try to build AOSP source tree and it somehow uses this module to generate "make-hash-tools.pl"但是,我最近尝试构建 AOSP 源代码树,它以某种方式使用此模块生成“make-hash-tools.pl”

The Mavericks has perl version of 5.16.2, and its predecessor Mountain Lion has a 5.12.4. Mavericks 的 perl 版本为 5.16.2,其前身 Mountain Lion 的 perl 版本为 5.12.4。 Is there a way to downgrade my Perl?有没有办法降级我的 Perl?

Compilation error looks like this:编译错误如下所示:

  Can't locate Switch.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-\ 
  multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level\
  /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2\
  /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16\
  /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level \
  /System/Library/Perl/Extras/5.16 .) at external/webkit/Source/WebCore\
  /make-hash-tools.pl line 23.

Thanks~!谢谢~!

You can use perlbrew to install a parallel version of Perl in its own directory with its own modules.您可以使用perlbrew将 Perl 的并行版本安装在其自己的目录中,并带有自己的模块。 Currently it lets you install Perl as far back as 5.003_07, although not all of them are supported by Perl Porters for security fixes.目前,它允许您安装 Perl,最早可以追溯到 5.003_07,尽管并非所有 Perl Porters 都支持它们以进行安全修复。

It would probably be simpler to install Switch from CPAN though.不过,从 CPAN 安装 Switch可能会更简单。

看起来像运行sudo cpanm Switch --force对我sudo cpanm Switch --force

you can also use this:你也可以使用这个:

$ sudo defaults write '/Library/Preferences/com.apple.versioner.perl' Version 5.12

It makes perl run version 12 for most stuff.它使大多数东西的 perl 运行版本 12。 Unfortunately, not for apache ...不幸的是,不适用于apache ...

Worked for me on 10.9.2, with no "force".在 10.9.2 上为我工作,没有“强制”。


cpan[2]> install Switch
Running install for module 'Switch'
Running make for C/CH/CHORNY/Switch-2.17.tar.gz
Fetching with LWP:

... bunch of fetch stuff ... ......一堆东西......

CPAN.pm: Building C/CH/CHORNY/Switch-2.17.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Switch
Writing MYMETA.yml and MYMETA.json

... a bunch of xcode license stuff ... ...一堆xcode许可证的东西...

cp Switch.pm blib/lib/Switch.pm
Manifying blib/man3/Switch.3pm
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/given.t ... ok       
t/nested.t .. ok   
t/switch.t .. ok       
All tests successful.
Files=3, Tests=590,  0 wallclock secs ( 0.04 usr  0.01 sys +  0.22 cusr  0.01 csys =  0.28 CPU)
Result: PASS
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make test -- OK
Running make install
Installing /Library/Perl/5.16/Switch.pm
Installing /usr/local/share/man/man3/Switch.3pm
Appending installation info to /Library/Perl/Updates/5.16.2/darwin-thread-multi-2level/perllocal.pod
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make install  -- OK

I then ran my code that previously pitched the "Can't locate Switch.pm in @INC" error, and the code ran fine.然后我运行了我之前抛出“Can't locate Switch.pm in @INC”错误的代码,并且代码运行良好。

I find these command works.我发现这些命令有效。

sudo perl -MCPAN -e shell

cpan > force install Switch 

I found another command :我找到了另一个命令:

sudo cpan -f Switch

I had to execute the command 2 times but for me it works on Yosemite.我不得不执行该命令 2 次,但对我来说它适用于优胜美地。 Thank s this blog .谢谢这个博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM