MENU

【AWS】Cloud9でlinuxbrewを使う

  • URLをコピーしました!

こんにちは、みーまです。

Cloud9でもやはりbrewは必要ですよね。今回はCloud9でbrewを使う方法を紹介します。

目次

標準の手順でインストールしてみた

インストールをしてみましたが、公式通りにいかないようでした。

以下のようになって進みません。

==> Checking for `sudo` access (which may request your password).
==> Select the Homebrew installation directory
- Enter your password to install to /home/linuxbrew/.linuxbrew (recommended)
- Press Control-D to install to /home/ec2-user/.linuxbrew
- Press Control-C to cancel installation

あなたはシステム管理者から通常の講習を受けたはずです。
これは通常、以下の3点に要約されます:

    #1) 他人のプライバシーを尊重すること。
    #2) タイプする前に考えること。
    #3) 大いなる力には大いなる責任が伴うこと。

[sudo] ec2-user のパスワード:

sudoに関連することかな?と調査していたのですが、visudoでの対処でも変化がなかったので、他の手順でインストールすることにしました。

ドキュメントにある他のコマンドでインストールできました。

Alternative Installation
Extract or git clone Homebrew wherever you want. Use /home/linuxbrew/.linuxbrew if possible (to enable the use of binary packages).

Cloud9でのインストール方法

ドキュメントを参考に以下のコマンドを実施します。

$ sudo yum groupinstall 'Development Tools' -y
$ sudo yum install procps-ng curl file git gcc gcc-c++ -y

$ git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
$ mkdir ~/.linuxbrew/bin
$ ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
$ echo 'eval $(~/.linuxbrew/bin/brew shellenv)' >> ~/.bashrc
$ exec $SHELL -l

ディレクトリが無いとメッセージが出るので、指示通りのディレクトリを作ります。

$ mkdir -p /home/ec2-user/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core
$ brew tap homebrew/core

インストールが成功し、バージョンが確認できるようになりました。

$ brew --version
Homebrew 3.2.6-39-g5ea678b
Homebrew/homebrew-core (git revision 377b59a74fd; last commit 2021-08-09)

anyenvも使えるようになりました。

$ brew install anyenv
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 2 formulae.

==> Downloading https://ghcr.io/v2/linuxbrew/core/anyenv/manifests/1.1.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/linuxbrew/core/anyenv/blobs/sha256:64a65deada2b73eea41aaf1072d015c193e46cc38d524e3770d8e319b56b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:64a65deada2b73eea41aaf1072d015c193e46cc38d524
######################################################################## 100.0%
==> Pouring anyenv--1.1.4.x86_64_linux.bottle.tar.gz
🍺  /home/ec2-user/.linuxbrew/Cellar/anyenv/1.1.4: 23 files, 30.5KB

以上、Cloud9でのbrewのインストール方法でした。

目次