Skip to content

Commit

Permalink
update posts - 2024-11
Browse files Browse the repository at this point in the history
  • Loading branch information
mnishiguchi committed Nov 30, 2024
1 parent dfd37bf commit ec5d0a4
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions public/20241130-asdfrc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: asdf の設定ファイル .asdfrc をつかってみた
tags:
- 設定
- asdf
- asdf-vm
- asdfrc
private: false
updated_at: '2024-11-30T18:54:47+09:00'
id: 11fccf5e2e4a23f49c89
organization_url_name: fukuokaex
slide: false
ignorePublish: false
---
[asdf]: https://asdf-vm.com/

## はじめに

[asdf] は、複数のプログラミング言語やツールのバージョンを統一的に管理できる便利なツールです。

[asdf] を利用する中で、設定ファイルである `.asdfrc` の便利さに氣づきました。

この記事では、`.asdfrc` の基本的な設定内容を整理し、学んだことを共有します。誰かの参考になれば幸いです。

https://qiita.com/torifukukaiou/items/9009191de6873664bb58

## `.asdfrc` の基本

[asdf] の設定ファイル `.asdfrc` は、デフォルトではホームディレクトリに配置されます。このファイルを利用することで、[asdf] の動作を細かくカスタマイズすることができます。

以下はデフォルトの設定内容です。

```bash
legacy_version_file = no
use_release_candidates = no
always_keep_download = no
plugin_repository_last_check_duration = 60
disable_plugin_short_name_repository = no
concurrency = auto
```

詳しくは[公式ドキュメントの `.asdfrc` 設定セクション](https://asdf-vm.com/manage/configuration.html#asdfrc)を参照してください。

### 各設定項目の説明

- **[`legacy_version_file`](https://asdf-vm.com/manage/configuration.html#legacy-version-file)**
既存のバージョン管理ツールのファイル(例: `.ruby-version`, `.node-version` など)を参照するかどうかを制御します。`yes` にすると互換性を持たせられます。

- **[`use_release_candidates`](https://asdf-vm.com/manage/configuration.html#use-release-candidates)**
リリース候補(RC)のバージョンを使用するかどうかを設定します。

- **[`always_keep_download`](https://asdf-vm.com/manage/configuration.html#always-keep-download)**
ダウンロードしたアーカイブを削除せず保持するかどうかを指定します。

- **[`plugin_repository_last_check_duration`](https://asdf-vm.com/manage/configuration.html#plugin-repository-last-check-duration)**
プラグインリポジトリの更新頻度(分単位)を指定します。デフォルトは 60 分です。

- **[`disable_plugin_short_name_repository`](https://asdf-vm.com/manage/configuration.html#disable-plugin-short-name-repository)**
プラグインの短縮名を使ったリポジトリを無効化します。

- **[`concurrency`](https://asdf-vm.com/manage/configuration.html#concurrency)**
並列処理の設定を行います。`auto` にすると環境に応じた適切な値が設定されます。

## レガシーファイルを参照する設定

僕が特に活用している `legacy_version_file` 設定について、もう少し詳しく説明します。

プロジェクト内に `.node-version``.ruby-version` など、既存のバージョン管理ツール用ファイルが存在する場合、それをそのまま活用することが可能です。この機能は、`legacy_version_file``yes` に設定することで有効になります。

以下のように `.asdfrc` を設定します。

```bash
legacy_version_file = yes
```

**ユースケース**:

- プロジェクト内で `rbenv``nvm` など他のバージョン管理ツールと [asdf] を併用している場合。
- 古いプロジェクトのファイルを `.tool-versions` に変換せずに活用したい場合。

ただし、[asdf] の推奨される運用は `.tool-versions` を利用することです。この設定は、あくまで暫定的な解決策として活用するのが良いでしょう。一方で、新しいプロジェクトでは `.tool-versions` を利用する運用に切り替えることで、後々の管理が楽になるとも考えています。この使い分けができる点も `.asdfrc` の魅力です。

詳細は[レガシーファイル設定](https://asdf-vm.com/manage/configuration.html#legacy-version-file)をご確認ください。

## 僕の `.asdfrc`

僕の `.asdfrc` 設定では、`legacy_version_file` のみを設定しています。この一つの設定項目で、既存のツールから [asdf] へのスムーズな移行が可能になり、プロジェクトごとの特性に合わせた柔軟な運用も実現できます。

これを設定することで、`.ruby-version``.node-version` といった既存のバージョン管理ツール用ファイルをそのまま活用できました。特に、古いプロジェクトをメンテナンスする際や、他のツールから [asdf] への移行作業を行う際に大きな助けとなりました。

## おわりに

`.asdfrc` は、[asdf] の柔軟性を高める便利な設定ファイルです。僕の場合、特に `legacy_version_file` の設定が役立ちました。既存のプロジェクトをスムーズに移行したり、古いバージョン管理ツール用ファイルをそのまま活用できたりする点は、非常に強力で便利です。

この記事が少しでも参考になれば嬉しいです。また、皆さんのおすすめのテクニックや工夫があれば、ぜひコメントなどで教えていただけると嬉しいです!

0 comments on commit ec5d0a4

Please sign in to comment.