💻

Mシリーズ Macで始める“素の”Scala 2.13開発環境構築ガイド

に公開

― Homebrew・Coursier・sbt だけで最小構成を作る ―

🥑 1. 前提ツール & バージョン

ツール 今回入れるバージョン インストール方法
Homebrew 最新 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Coursier (cs)Scala エコシステム公式ランチャー - brew install coursier/formulas/coursier
JDK 17 brew install temurin

🛠 2. Scala & Scalac を Coursier でインストール

# ❶ Scala REPL(実行ランチャ)
cs install scala:2.13.14

# ❷ Scala コンパイラ
cs install scalac:2.13.14

✔ 動作確認

scala -version   # => Scala code runner version 2.13.14
scalac -version  # => Scala compiler version 2.13.14

📦 3. sbt(ビルドツール)を導入

brew install sbt
  • 初回起動は Scala 2.12(sbt 用) や各種プラグインをダウンロードするので 30 s〜数分待ち
  • Apple Silicon でもネイティブ ARM バイナリが入り、Rosetta は不要

✨ 4. sbt new でプロジェクト雛形を作成

4-1 テンプレートの指定に注意!

コマンドは GitHub オーナー/リポジトリ を書く:

sbt new scala/scala-seed.g8   # ← Scala 2.13 用ミニマム
  • 単に scala-seed.g8 だけだと “Template not found” エラーになる
  • Scala 3 が欲しい場合は sbt new scala/scala3.g8

4-2 生成〜実行

A minimal Scala project.
name [Scala Seed Project]: scala-hello
cd scala-hello
sbt run
  • 大量の WARNING: sun.misc.Unsafe は Zero-Allocation-Hashing ライブラリの内部呼び出し。現状は無害
  • 最終行が hello になれば成功 👏

Discussion