LoginSignup
42
32

More than 5 years have passed since last update.

AWS Cloud9でHerokuのインストールが毎回必要?になる(Railsチュートリアル )

Posted at

前提

RailsチュートリアルをAWS Cloud9を使ってやってます。

問題

railsチュートリアルの一章でherokuのインストールをしたが、AWS Cloud9に入りなおす度にherokuコマンドがないといわれ、毎回インストールコマンドを実行していた。
(ちなみにインストールコマンドを実行するとherokuコマンドが使えるようになるが、エラーが出ていた。)

1章のherokuインストールコマンド
source <(curl -sL https://cdn.learnenough.com/heroku_install)
2回目以降に実行した時のエラー
mv: cannot move ‘heroku’ to ‘/usr/local/heroku’: Directory not empty

解決

なんとなくインストールコマンドのcurlだけで実行してみる。

コマンド
curl -sL https://cdn.learnenough.com/heroku_install
結果
curl -OL https://cli-assets.heroku.com/heroku-linux-x64.tar.gz
tar zxf heroku-linux-x64.tar.gz && rm -f heroku-linux-x64.tar.gz
sudo mv heroku /usr/local
echo 'PATH=/usr/local/heroku/bin:$PATH' >> $HOME/.profile
source $HOME/.profile > /dev/null

結果を見ると「\$HOME/.profile」に\$PATHの設定を追加してる。
けどbashの設定ファイルって「.profile」だっけ?と思い調べるとbashの設定ファイル「.bash_profile」らしい。
ということで「\$HOME/.bash_profile」に$PATHの設定を追加して再起動してみる。

.bash_profile追加
PATH=/usr/local/heroku/bin:$PATH

再起動後herokuコマンドが使用できた!

参考

bashで環境変数(PATH)の設定
https://qiita.com/iam1at/items/91cb8478160c9fbee134

curlコマンドでapiを叩く
https://qiita.com/bunty/items/758425773b2239feb9a7

42
32
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
42
32