0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

個人調査備忘録:mise

Posted at

個人調査備忘録 mise

目的

新しい技術のキャッチアップのために書いていく
個人レベルのメモです。

公式サイトから確認

mise公式サイト

About

Aboutを確認してみると、下記の3つの機能があるよう

  • 開発ツールのインストール、管理
  • 環境変数の管理
  • タスクの起動

開発ツールのインストール、管理

Demoではmiseコマンドで言語やツールインストールを行なっていた。

  1. miseのインストール
    Getting Started
$ curl https://mise.run | sh
$ ~/.local/bin/mise --version
              _                                        __
   ____ ___  (_)_______        ___  ____        ____  / /___ _________
  / __ `__ \/ / ___/ _ \______/ _ \/ __ \______/ __ \/ / __ `/ ___/ _ \
 / / / / / / (__  )  __/_____/  __/ / / /_____/ /_/ / / /_/ / /__/  __/
/_/ /_/ /_/_/____/\___/      \___/_/ /_/     / .___/_/\__,_/\___/\___/
                                            /_/                 by @jdx
2025.7.0 linux-x64 (2025-07-01)

$ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

  1. miseによるインストール
$ mise exec python@3 -- python
mise hint use multiple versions simultaneously with mise use python@3.12 python@3.11
mise hint installing precompiled python from astral-sh/python-build-standalone
if you experience issues with this python (e.g.: running poetry), switch to python-build by running mise settings python.compile=1
mise python@3.13.5 ✓ installed                                                  Python 3.13.5 (main, Jun 29 2025, 16:24:12) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

# pythonコマンド自体にはパスが通っていない?
$ python -v
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3

# でもmise上ではpythonが管理されているように見える
$ mise ls
Tool    Version  Source  Requested
python  3.13.5

# miseの起動
$ echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
$ source ~/.bashrc
  1. miseで取得したツールの実行
$ mkdir mise_pj;cd mise_pj

# mise_pj配下でgo言語を入れてみる
$ mise exec go -- go
$ mise go@1.24.4 ✓ installed

$ go version
go version go1.24.4 linux/amd64

# goをインストールしたフォルダの親フォルダではgoのパスが通っていない
$ cd ..
$ go version
Command 'go' not found, but can be installed with:
sudo snap install go         # version 1.24.2, or
sudo apt  install golang-go  # version 2:1.21~2
sudo apt  install gccgo-go   # version 2:1.21~2
See 'snap info go' for additional versions.

開発ツールのインストール、管理は上記の意味かな
mise execとかuse,lsでインストールやver管理ができる

環境変数の管理

projectフォルダ内のmise.tomlから環境変数の設定ができるらしい

$ cat mise.toml
[tools]
go = "latest"
python = "3"
$ mise set MY_VAR=123
$ echo $MY_VAR
123
$ cat mise.toml
[tools]
go = "latest"
python = "3"

[env]
MY_VAR = "123"

# 本体の環境変数も書き換わっているみたい(プロジェクトのフォルダ内限定)
$ env | grep MY_VAR
MY_VAR=123

$ cd ..
$ env | grep MY_VAR
$

じゃあ、本体とmiseの環境変数を競合させたらどうなるんだ?

# プロジェクト外のフォルダで環境変数設定
$ export MY_VAR=345
$ echo $MY_VAR
345

# プロジェクト内のフォルダで確認
$ cd mise_pj
$ echo $MY_VAR
123
$ env | grep MY_VAR
MY_VAR=123

# プロジェクト内のフォルダで環境変数設定
$ export MY_VAR=567
$ echo $MY_VAR
567

# mise.tomlを確認してみたが、書き換わっていない
$ cat mise.toml
[tools]
go = "latest"
python = "3"

[env]
MY_VAR = "123"

# プロジェクト外のフォルダで確認
$ cd ..
$ echo $MY_VAR
345

なのでプロジェクト内では環境変数はmise.tomlが優先される
プロジェクト外では本体の環境変数が優先
プロジェクト内の環境変数設定は基本的に上書きなので最後の上書きに依存する

環境変数の管理はmise.tomlでされるようだ

タスクの起動

mise run xxxで設定したコマンドが実行できるよう

# tasks.testを新規に作成
$ cat mise.toml
[tools]
go = "latest"
python = "3"

[env]
MY_VAR = "123"

[tasks.test]
description = "task機能の動作確認"
run = "echo 'これはtask機能を確かめるためのechoです'"

$ mise run test
[test] $ echo 'これはtask機能を確かめるためのechoです'
これはtask機能を確かめるためのechoです

タスクの起動としては上記のような形になる
再現性のあるコマンドを実行する感じか

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?