初稿: 2018-08-11 Sat 14:11
最終更新日: 2018-12-14 Fri 20:44
ホーム | 文書トップ | 目次

plenv
pyenvをリスペクトしたperl用バージョン管理コマンド

目次

1 plenv とは

plenv とは pyenv をリスペクトしたperl用バージョン管理コマンドです。

pyenv と同じ操作感でperlのバージョン管理を行うことができます。

2 インストール

anyenv を使ってインストールします。 anyenv のインストールをされていない方はこちら

 1: > anyenv versions
 2: goenv:
 3: Warning: no Go detected on the system
 4: 
 5: ndenv:
 6: * v10.7.0 (set by /Users/conao/.anyenv/envs/ndenv/version)
 7: plenv:
 8: * system (set by /Users/conao/.anyenv/envs/plenv/version)
 9: pyenv:
10:   system
11: * 2.7.15 (set by /Users/conao/.anyenv/envs/pyenv/version)
12: * 3.7.0 (set by /Users/conao/.anyenv/envs/pyenv/version)
13: rbenv:
14: * system (set by /Users/conao/.anyenv/envs/rbenv/version)
15: 
16: > plenv install --list
17: Available versions:
18:  5.29.1
19:  5.29.0
20:  5.28.0
21:  5.28.0-RC4
22:  5.28.0-RC3
23:  5.28.0-RC2
24:  5.28.0-RC1
25:  5.27.11
26:  5.27.10
27:  ...
28: 
29: $ plenv install 5.26.1
30: $ plenv versions
31: * system (set by /Users/conao/.anyenv/envs/plenv/version)
32:   5.26.1
33: $ plenv global 5.26.1
34: $ perl -v
35: 
36: This is perl 5, version 26, subversion 1 (v5.26.1) built for darwin-2level
37: (with 1 registered patch, see perl -V for more detail)
38: 
39: Copyright 1987-2017, Larry Wall
40: 
41: Perl may be copied only under the terms of either the Artistic License or the
42: GNU General Public License, which may be found in the Perl 5 source kit.
43: 
44: Complete documentation for Perl, including FAQ lists, should be found on
45: this system using "man perl" or "perldoc perl".  If you have access to the
46: Internet, point your browser at http://www.perl.org/, the Perl Home Page.

3 599 Internal Exceptionエラーが出る場合

1: $ pyenv install --list
2: Available versions:
3: 599 Internal Exception, https://fastapi.metacpan.org/v1/release/_search,
4: Can't verify SSL peers without knowing which Certificate Authorities to trust  
5: This problem can be fixed by either setting the PERL_LWP_SSL_CA_FILE envirionment 
6: variable or by installing the Mozilla::CA module.  
7: To disable verification of SSL peers set the PERL_LWP_SSL_VERIFY_HOSTNAME 
8: envirionment variable to 0.  
9: If you do this you can't be sure that you communicate with the expected peer.'

githubのissueより次のパッチを当てる。

 1: --- perl-build-bak      2018-08-11 14:07:11.000000000 +0900
 2: +++ perl-build  2018-08-11 14:08:21.000000000 +0900
 3: @@ -10258,7 +10258,7 @@ $fatpacked{"HTTP/Tinyish/HTTPTiny.pm"} =
 4:  HTTP_TINYISH_HTTPTINY
 5: 
 6:  $fatpacked{"HTTP/Tinyish/LWP.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'HTTP_TINYISH_LWP';
 7: -  package HTTP::Tinyish::LWP;use strict;use parent qw(HTTP::Tinyish::Base);use LWP 5.802;use LWP::UserAgent;my%supports=(http=>1);sub configure {my%meta=(LWP=>$LWP::VERSION,);if (eval {require LWP::Protocol::https;1}){$supports{https}=1;$meta{"LWP::Protocol::https"}=$LWP::Protocol::https::VERSION}\%meta}sub supports {$supports{$_[1]}}sub new {my($class,%attr)=@_;my$ua=LWP::UserAgent->new;bless {ua=>$class->translate_lwp($ua,%attr),},$class}sub _headers_to_hashref {my($self,$hdrs)=@_;my%headers;for my$field ($hdrs->header_field_names){$headers{lc$field}=$hdrs->header($field)}\%headers}sub request {my($self,$method,$url,$opts)=@_;$opts ||= {};my$req=HTTP::Request->new($method=>$url);if ($opts->{headers}){$req->header(%{$opts->{headers}})}if ($opts->{content}){$req->content($opts->{content})}my$res=$self->{ua}->request($req);if ($self->is_internal_response($res)){return$self->internal_error($url,$res->content)}return {url=>$url,content=>$res->decoded_content(charset=>'none'),success=>$res->is_success,status=>$res->code,reason=>$res->message,headers=>$self->_headers_to_hashref($res->headers),protocol=>$res->protocol,}}sub mirror {my($self,$url,$file)=@_;my$res=$self->{ua}->mirror($url,$file);if ($self->is_internal_response($res)){return$self->internal_error($url,$res->content)}return {url=>$url,content=>$res->decoded_content,success=>$res->is_success || $res->code==304,status=>$res->code,reason=>$res->message,headers=>$self->_headers_to_hashref($res->headers),protocol=>$res->protocol,}}sub translate_lwp {my($class,$agent,%attr)=@_;$agent->parse_head(0);$agent->env_proxy;$agent->timeout(delete$attr{timeout}|| 60);$agent->max_redirect(delete$attr{max_redirect}|| 5);$agent->agent(delete$attr{agent}|| "HTTP-Tinyish/$HTTP::Tinyish::VERSION");unless ($attr{verify_SSL}){if ($agent->can("ssl_opts")){$agent->ssl_opts(verify_hostname=>0)}}if ($attr{default_headers}){$agent->default_headers(HTTP::Headers->new(%{$attr{default_headers}}))}$agent}sub is_internal_response {my($self,$res)=@_;$res->code==500 && ($res->header('Client-Warning')|| '')eq 'Internal response'}1;
 8: +  package HTTP::Tinyish::LWP;use strict;use parent qw(HTTP::Tinyish::Base);use LWP 5.802;use LWP::UserAgent;my%supports=(http=>1);sub configure {my%meta=(LWP=>$LWP::VERSION,);if (eval {(require LWP::Protocol::https;1) && (require Mozilla::CA; 1)}){$supports{https}=1;$meta{"LWP::Protocol::https"}=$LWP::Protocol::https::VERSION}\%meta}sub supports {$supports{$_[1]}}sub new {my($class,%attr)=@_;my$ua=LWP::UserAgent->new;bless {ua=>$class->translate_lwp($ua,%attr),},$class}sub _headers_to_hashref {my($self,$hdrs)=@_;my%headers;for my$field ($hdrs->header_field_names){$headers{lc$field}=$hdrs->header($field)}\%headers}sub request {my($self,$method,$url,$opts)=@_;$opts ||= {};my$req=HTTP::Request->new($method=>$url);if ($opts->{headers}){$req->header(%{$opts->{headers}})}if ($opts->{content}){$req->content($opts->{content})}my$res=$self->{ua}->request($req);if ($self->is_internal_response($res)){return$self->internal_error($url,$res->content)}return {url=>$url,content=>$res->decoded_content(charset=>'none'),success=>$res->is_success,status=>$res->code,reason=>$res->message,headers=>$self->_headers_to_hashref($res->headers),protocol=>$res->protocol,}}sub mirror {my($self,$url,$file)=@_;my$res=$self->{ua}->mirror($url,$file);if ($self->is_internal_response($res)){return$self->internal_error($url,$res->content)}return {url=>$url,content=>$res->decoded_content,success=>$res->is_success || $res->code==304,status=>$res->code,reason=>$res->message,headers=>$self->_headers_to_hashref($res->headers),protocol=>$res->protocol,}}sub translate_lwp {my($class,$agent,%attr)=@_;$agent->parse_head(0);$agent->env_proxy;$agent->timeout(delete$attr{timeout}|| 60);$agent->max_redirect(delete$attr{max_redirect}|| 5);$agent->agent(delete$attr{agent}|| "HTTP-Tinyish/$HTTP::Tinyish::VERSION");unless ($attr{verify_SSL}){if ($agent->can("ssl_opts")){$agent->ssl_opts(verify_hostname=>0)}}if ($attr{default_headers}){$agent->default_headers(HTTP::Headers->new(%{$attr{default_headers}}))}$agent}sub is_internal_response {my($self,$res)=@_;$res->code==500 && ($res->header('Client-Warning')|| '')eq 'Internal response'}1;
 9:  HTTP_TINYISH_LWP
10: 
11:  $fatpacked{"HTTP/Tinyish/Wget.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'HTTP_TINYISH_WGET';

見にくいですが、170桁くらいのif文を変更します。

1: - if (eval {require LWP::Protocol::https;1})
2: + if (eval {(require LWP::Protocol::https;1) && (require Mozilla::CA; 1)})

日付: 2018-08-11 Sat 14:11

著者: conao

Created: 2018-12-14 Fri 21:04

Validate