Rails 4 + PostgreSQL hstore, cannot execute "CREATE EXTENSION hstore"

I have RubyOnRails 4.1.4 and PostgreSQL installed on my MacOS X:

brew install postgresql 

When I try to migrate:

 CREATE EXTENSION hstore 

It gives me an error message:

 PG::UndefinedFile: ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/hstore.control": No such file or directory 

I tried to find "hstore.control" in the file system using:

 find / -name "hstore.control" 

And I found out that this file is in a different path:

 usr/local/Cellar/postgresql/9.3.4/share/postgresql/extension/hstore.control 

So, how can I override the gem configuration "PG" to fix the hstore extension path? I just tried to remove the gem and install it with:

 rvm all do gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.4/bin/pg_config 

But that did not work. I still have the same error.

Thanks in advance.

UPDATE:

I just created a symlink for the right path, but either way it gives me the same error.

+6
source share
3 answers

OK, I just created a symlink, reinstalled gem pg , and now everything works fine.

0
source

The solution is simple, just install postgresql-contrib in your OS, and then migrate, as shown here by Rails 4 PostgreSQL integration or in any other way that you use, For example, if you use ubuntu, it will be:

 sudo apt-get install postgresql-contrib-XX 

where XX is the version of postgresql you are using. If it is version 9.3, it will be:

 sudo apt-get install postgresql-contrib-9.3 

I also think that for MAC Os it is almost the same, only that you will use brew.

+27
source

This link helped me. We need to install postgresql-contrib before trying to create the HStore extension.

https://gist.github.com/terryjray/3296171

+3
source

Source: https://habr.com/ru/post/972010/


All Articles