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?

More than 3 years have passed since last update.

AmberのGetting Startedをやってみたら詰まった話

Last updated at Posted at 2021-10-15

はじめに

Rubyに似た構文を持つ静的型付けのコンパイル言語Crystalを知って、少し触ってみようとCrystalのWeb FrameworkであるAmberGetting Startedをやってみたら動かなかったのでどうにかしたときの備忘録です。

WSL2上で行ったため、WSL2のタグをつけていますがWSL2特有ではないと思います。

バージョンなど

  • OS Ubuntu20.04
  • Crystal 1.2.0
  • Amber 1.0.0rc2

Amberのインストール

AmberのGitHubにあるインストール方法はmakeでエラーになります。原因はshards installをしていまいとshard.lockが存在しないためです。またmake installは権限を要求するので正しくは下記のようにインストールする必要があります。

sudo apt-get install libreadline-dev libsqlite3-dev libpq-dev libmysqlclient-dev libssl-dev libyaml-dev libpcre3-dev libevent-dev
curl -L https://github.com/amberframework/amber/archive/stable.tar.gz | tar xz
cd amber-stable/
shards install
sudo make install

Error: undefined constant GarnetSpec::Controller::Test

amber watchを実行した際に上記のエラーが発生しました。garnet_specに由来するもののようだが原因はよくわからなかったです。shard.ymlの記述を変更し、garnet-specのバージョンを0.2.1に変更することでエラーが消えます。

development_dependencies:
  garnet_spec:
    github: amberframework/garnet-spec
    version: 0.2.1
  ameba:
    github: crystal-ameba/ameba
    version: ~> 0.13.4

shard.yml編集後以下を実行

shards install

--: 1: npm: not found

amber watchはnpmが必要らしいです。普通にnpmをインストールすればいいです。

sudo apt install npm

最後に

とりあえずCrystal&Amberが触れる環境が作れたのでこれからいろいろ試してみたいと思います。
Rubyと似ているので学習コストは低そうな気がする?
AmberもRailsに大分似ているので意外と簡単に使えるかもしれない。(ただ、Rails7でだいぶフロントエンドが変わるらしいのでどっちがいいとか言いにくい感じがある)

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?