Carton-v1.0.12 > Carton

名前

Carton - Perl module dependency manager (aka Bundler for Perl)

Carton - Perl module 依存マネージャー(aka Perl用 Bundler)

概要

  # On your development environment
  > cat cpanfile
  requires 'Plack', '0.9980';
  requires 'Starman', '0.2000';

  > carton install
  > git add cpanfile cpanfile.snapshot
  > git commit -m "add Plack and Starman"

  # Other developer's machine, or on a deployment box
  > carton install
  > carton exec starman -p 8080 myapp.psgi

可用性

Carton only works with perl installation with the complete set of core modules. If you use perl installed by a vendor package with modules stripped from core, Carton is not expected to work correctly.

Carton は 完全なコアモジュールのセットと一緒にインストールされた perl でのみ 動きます。コアから分離された、ベンダーパッケージによってインストールされた Perlを使うなら、Carton は正確に動かないでしょう。

Also, Carton requires you to run your command/application with carton exec command, which means it's difficult or impossible to run in an embedded perl use case such as mod_perl.

また、Cartonは、carton execコマンドで、あなたのコマンド/アプリケーションを 動かすことを要求します。つまり、mod_perlのような組み込みのPerlのユースケースでは、 Cartonを使うのは、難しいか不可能という事です。

説明

carton is a command line tool to track the Perl module dependencies for your Perl application. Dependencies are declared using cpanfile format, and the managed dependencies are tracked in a cpanfile.snapshot file, which is meant to be version controlled, and the snapshot file allows other developers of your application will have the exact same versions of the modules.

carton は、アプリケーションのPerlモジュールの依存を追跡する コマンドラインツールです。依存は cpanfile フォーマットを使って 宣言されます。管理された依存は、cpanfile.snapshotファイルに 跡が残ります、これをバージョンコントロールします。 スナップショットファイルによって、あなたのアプリケーションの他の開発者は、 まったく同じバージョンのモジュールを持つことができるようになります。

For cpanfile syntax, see cpanfile documentation.

cpanfileのシンタックスは、cpanfileドキュメントを読んでください。

チュートリアル

環境を初期化する

carton will use the local directory to install modules into. You're recommended to exclude these directories from the version control system.

carton は、local ディレクトリをモジュールをインストールするディレクトリに使います。 バージョンコントロールシステムからそれらのディレクトリを除外することを推奨します。

  > echo local/ >> .gitignore
  > git add cpanfile cpanfile.snapshot
  > git commit -m "Start using carton"

依存の追跡

You can manage the dependencies of your application via cpanfile.

cpanfile でアプリケーションの依存を管理できます。

  # cpanfile
  requires 'Plack', '0.9980';
  requires 'Starman', '0.2000';

And then you can install these dependencies via:

依存を以下のようにしてインストールできます:

  > carton install

The modules are installed into your local directory, and the dependencies tree and version information are analyzed and saved into cpanfile.snapshot in your directory.

モジュールは local ディレクトリにインストールされ、依存ツリーと バージョン情報は解析されて、ディレクトリ内の cpanfile.snapshot に保存されます。

Make sure you add cpanfile and cpanfile.snapshot to your version controlled repository and commit changes as you update dependencies. This will ensure that other developers on your app, as well as your deployment environment, use exactly the same versions of the modules you just installed.

cpanfilecpanfile.snapshot をバージョンコントロールリポジトリに 加えたことを確認して、依存を更新した際には、変更をコミットしてください。 あなたのアプリケーションの他の開発者が、あなたのデプロイメント環境と同様の、 あなたがインストールしたのと、ちょうど同じバージョンのモジュールを使う ことを保証します。

  > git add cpanfile cpanfile.snapshot
  > git commit -m "Added Plack and Starman"

アプリケーションをデプロイする

Once you've done installing all the dependencies, you can push your application directory to a remote machine (excluding local and .carton) and run the following command:

全ての依存をインストールしたら、アプリケーションディレクトリを リモートのマシーンに(local.carton を除いて)、プッシュし、 以下のコマンドを実行します:

  > carton install --deployment

This will look at the cpanfile.snapshot and install the exact same versions of the dependencies into local, and now your application is ready to run.

このコマンドは、cpanfile.snapshot を見て、ちょうど同じバージョンの依存を local にインストールします。これで、アプリケーションを実行する準備ができました。

The --deployment flag makes sure that carton will only install modules and versions available in your snapshot, and won't fallback to query for CPAN Meta DB for missing modules.

--deployment フラグは、carton がスナップショット内の利用可能なモジュールと バージョンのみをインストールしようとします。失われたモジュールのために、 CPAN Meta DB に問い合わせるフォールバックをしません。

モジュールのビルド

carton can bundle all the tarballs for your dependencies into a directory so that you can even install dependencies that are not available on CPAN, such as internal distribution aka DarkPAN.

carton は、依存のための 全てのtarボールをディレクトリにいれてバンドルできます。 そのため、CPANで、または、いわゆるDarkPANのような内部のディストリビューション上にあり、 利用可能でない依存をインストールすることさえ出来ます。

  > carton bundle

will bundle these tarballs into vendor/cache directory, and

vendor/cacheディレクトリに、それらの tarボール をバンドルして、

  > carton install --cached

will install modules using this local cache. Combined with --deployment option, you can avoid querying for a database like CPAN Meta DB or downloading files from CPAN mirrors upon deployment time.

ローカルキャッシュを使って、モジュールをインストールします。 --deploymentオプションを組み合わせると、デプロイメント時に CPAN Meta DBのようなデータベースに問い合わせたり、 CPANミラーからファイルをダウンロードするのを避けることができます。

PERLのバージョン

When you take a snapshot in one perl version and deploy on another (different) version, you might have troubles with core modules.

1つの perl のバージョンでスナップショットをとり、他の(違う)バージョンに デプロイする時、コアモジュールに関してトラブルが起きるかもしれません。

The simplest solution, which might not work for everybody, is to use the same version of perl in the development and deployment.

もっとも簡単な解決策は、全ての人に有効かわかりませんが、開発とデプロイに 同じ perl のバージョンを使うことです。

To enforce that, you're recommended to use plenv and .perl-version to lock perl versions in development.

これを強制するには、plenv.perl-version を使って、 開発での perl のバージョンをロックすることを推奨します。

You can also specify the minimum perl required in cpanfile:

cpanfile で必要とされる最小の perl を指定することもできます:

  requires 'perl', '5.16.3';

and carton (and cpanm) will give you errors when deployed on hosts with perl lower than the specified version.

指定されたバージョンより小さい perl でホストにデプロイすると、 carton (と cpanm) は、は、エラーを出します。

コミュニティ

https://github.com/miyagawa/carton

Code repository, Wiki and Issue Tracker

コードリポジトリと Wiki とイシュートラッカー。

irc://irc.perl.org/#carton

IRC chat room

IRC チャットルーム

作者

Tatsuhiko Miyagawa

コピーライト

Tatsuhiko Miyagawa 2011-

ライセンス

This software is licensed under the same terms as Perl itself.

SEE ALSO

cpanm

cpanfile

Bundler

pip

npm

perlrocks

only