2

Using Rails 3.2.2, finishing up my migration from sqlite to postgres 9.2. Used answer in this tutorial as a guide to install postgres and got stuck on Step 11 where it asks run heroku db:pull where I get:

Failed to connect to database: Sequel::AdapterNotFound -> LoadError: cannot load such file --pg

I dug deeper and found db:pull (taps gem) is deprecated and came across a few recommendations for pg:transfer. Installed pg:transfer, but I get the impression it may be *nix only(?) as if I run: heroku pg:transfer it returns:

Heroku client internal error. No such file or directory - .env (Errno:ENOENT)

If I do pg:transfer with -f and -t it gives me: 'env' is not recognized as an internal or external command, operable program or batch file which means it isn't bound to path or doesn't exist as a command in windows.

Any thoughts on above errors?

Community
  • 1
  • 1
JStandard
  • 53
  • 8

2 Answers2

1

Resolved by using pg:backups gem, which was recommended as the replacement for taps in the Heroku docs. I used this guide and uploaded my dump to dropbox for Heroku to pick it up.

Here's my exact list of steps and cmds:

  1. Added pgbackups from heroku.com add-ons to my instance.
  2. heroku pgbackups:capture DATABASE (this just backs up your heroku db)
  3. pg_dump -h localhost -U <pg username> -Fc dbname > dbname.dump
  4. Moved dbname.dump into a folder on my dropbox
  5. In Dropbox, right-click on dbname.dump => "Share link"
  6. Cancel the sharing dialogue pop-up, right-click on "Download button", Copy Link Address (Chrome)
  7. heroku pgbackups:restore DATABASE <paste dropbox download link here>

Dropbox trickiness: don't use the file link provided by Dropbox since it's an html redirect and will cause pg:restore to fail, even though the extension ends in .dump

Instead, navigate to your dropbox page and "right-click copy link address" on the Download button. That's the address you use in your pgbackups:restore (should be something like db.dump?token=<long random string>)

A bit clunky, but got the job done. If you know a better way please let me know!

JStandard
  • 53
  • 8
0

You need to make a .env file containing something like:

DATABASE_URL=postgres://localhost/myapp_development

References:

Woahdae
  • 4,951
  • 2
  • 28
  • 26
  • I placed a "myapp.env" file in the root of my application with the one line about setting the DATABASE_URL and then ran `heroku pg:transfer` and it still through the `.env not found` error. Should it go in my app root? – JStandard Apr 15 '13 at 03:30
  • 1
    Also sidenote, I heard back from pg:transfer author ddollar, who mentioned he doesn't think pg:transfer will work in Windows. – JStandard Apr 15 '13 at 03:32
  • The specific error, to my recollection, was about trying to read a file called `.env` (not `myproject.env`) in the project root. Heroku doesn't require that you have a `.env` file, and might support alternate syntaxes, but `pg:transfer` itself seemed to be looking for `.env`. Additionally, however, it might not work on windows. Can't speak to that, only to the file-not-found error I had. – Woahdae Apr 15 '13 at 16:19
  • 1
    thx, you're absolutely right it's looking for just named ".env" Out of curiosity I persevered a bit more and you have to cmdline rename the file (gui won't accept extension only names), but then it can't find database URL so you have to create it. It spirals into a bigger mess from there so I decided to stick with pgbackups for now – JStandard Apr 15 '13 at 22:38