論盡蛋
心で書く

Blog


Unknown Heroku pull not working

According to this article, we can use heroku pull to export data from heroku's db to local db.

(Pulling my blog's posts down for the test of changing markdown engine)

However, I am getting this error:

!    Taps Load Error: cannot load such file -- taps/operation
!    You may need to install or update the taps gem to use db commands.
!    On most systems this will be:
!
!    sudo gem install taps

OK, it asked me to install taps, so I ran gem install taps (without sudo intendedly).

Then I ran again heroku pull, now a slightly different error occurred:

!    Taps Load Error: cannot load such file -- sqlite3
!    You may need to install or update the taps gem to use db commands.
!    On most systems this will be:
!
!    sudo gem install taps

What? install taps again..? But you mentioned cannot load sqlite3. I didn't use sqlite3 in this project, maybe taps internally uses sqlite3? OK, I try to install sqlite3 with gem install sqlite3.

Finally heroku pull works.


我的 SSH config

如果你跟我一樣有用 Heroku,相信你都有遇到過有兩個 accounts 的問題。每個 ssh key 只能上傳到一個 account。假如你想 git clone 兩個不同 account 的 projects 的話,就會發現單純 heroku login 幫不到忙。

這是因為 git clone 靠 ssh 來 authenticate 的。但 heroku login 不會更改你的 ssh keys,也不會自動選用合適的那條 key。

一個簡單的解決方法就是用 ~/.ssh/config

現況

首先先說明一下我的實際情況。

  1. 個人 account
    • peter@peterwongpp.com
    • ssh key: ~/.ssh/id_rsa
  2. 公司 account
    • peter@primitus.com
    • ssh key: ~/.ssh/primitus_heroku

這兩條 keys 以以下分式 upload 的:

#!bash
$ heroku login
Email: peter@peterwongpp.com
Password (typing will be hidden):
Authentication successful.

$ heroku keys:add
Found the following SSH public keys:
1) id_rsa.pub
2) primitus_heroku.pub
Which would you like to use with your Heroku account? 1

$ heroku login
Email: peter@primitus.com
Password (typing will be hidden):
Authentication successful.

$ heroku keys:add
Found the following SSH public keys:
1) id_rsa.pub
2) primitus_heroku.pub
Which would you like to use with your Heroku account? 2

問題

但現在應該會有如下的 error:

#!bash
$ git clone git@heroku.com:primitus-project.git
Cloning into 'primitus-project'...

 !  Your key with fingerprint ...... is not authorized to access primitus-project.

fatal: The remote end hung up unexpectedly

解決

首先是 ~/.ssh/config(如沒有請自行建立)

#!bash
Host HerokuPrimitus
  HostName heroku.com
  User git
  IdentityFile ~/.ssh/primitus_heroku
  IdentitiesOnly yes

簡單來說就是用 HerokuPrimitus 來代替 heroku.com,但指定了 ssh key。(另外也可以指定 port number etc)

然後是再來 git clone

#!bash
$ git clone git@HerokuPrimitus.com:primitus-project.git
Cloning into 'primitus-project'...
remote: Counting objects: ......