Postgres insufficient privilege

postgresql

#1

My tests pass locally, but on Circle they fail with this error:

ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: could not open file.

My tests write files to the “/tmp” directory.

circle.yml

database:
  override:
    - bin/setup
test:
  override:
    - COVERAGE=true bin/rake

#2

Can you share the part of your code that causes this error?


#3

I can only post one link apparently, but here are the tests:
https://github.com/SturdyCo/aact2/blob/csv/spec/models/ table_exporter_spec.rb

The code it’s running is in the TableExporter model in the same repo.


#4

Now the build is failing with: No such file or directory @ dir_initialize - /home/ubuntu/aact2/tmp

I assume this is because I am trying to write files to the tmp directory, which is not in source control. I have code in the TableExporter model that will try to create a tmp directory if none exists, but that doesn’t seem to be working.


#5

Solved! Added a post checkout hook to my circle.yml to create the tmp directory.


#6