Postgresql via homebrew vs. mountain lion OS X - ruby-on-rails-3

This is bothering me to no end.
I'm setting up a Rails 3.2 environment with Postgresql on my Mac with OS 10.8.2 (Mountain Lion).
I basically followed the directions in the Railscast, and installed postgresql version 9.2.0 via Homebrew. but whenever I do
which psql
and
psql --version
it always shows me the location and version of the system postgresql that came preinstalled with Mountain Lion (/usr/bin/psql and version 9.1.4, respectively), rather than the location and version of the Postgresql that I installed with Homebrew (/usr/local/bin and version 9.2.0, respectively).
I also set up a Launch Agent, so that postgresql automatically starts up when I start the system.
I've even tried following the directions from this blog, and I still get the same results when I run which psql.
However, when I do:
ps -ef | grep postgres
I receive the following results:
501 556 120 0 Fri02AM ?? 0:00.12 /usr/local/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
Does this mean that I'm running the homebrew version of postgresql?
Do I have to uninstall the system postgresql?

Another option would be to use Heroku's Postgres.app, I personally find this a bit easier to setup and manage.
http://postgresapp.com/

by adding directory path (/usr/local/bin) to the config file, ~/.bash_profile you will get resolve the above issue.
to know more refer this link.

If you use Postgres.app from Heroku, by adding
export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH
to ~/.bash_profile, it should resolve the issue.

Try adding:
export PATH=/usr/local/bin:$PATH
in your ~/.bash_profile
I think this works for when you install Postgres via Homebrew

Related

problems with Arch linux installation commands

It's my first time trying to install and using Arch linux, I was trying to install it in VirtualBox in Mac Os mojave, when i did arch-chroot /mnt(after all the configuration), then tried to nano /etc/locale.conf it just printed command not found.
I've already tried with vim or other commands like sudo or apt to install a plain text editor but it's always the same and I also tried twice but nothing changes.
PLEEAAASE, I need help.
In Archlinux you should use pacman -S to install packages
try this :
"pacman -S nano"
you can see more information here:
https://wiki.archlinux.org/index.php/pacman#Installing_packages
You can install it with the Linux kernel etc.
For installing the kernel you use
pacstrap
so just add nano, vim or whatever text-editor you like to use.
For more information: https://wiki.archlinux.org/index.php/Installation_guide

httpd not showing/using most updated version of apache (via brew)

I just installed the latest version of Apache (2.4.43) using brew on Mac OS (10.14.5). (Using instructions from this site.) But after restarting the service, httpd -v still shows 2.4.34 running from the Mac OS default. The same old version is shown when I query apachectl -v.
Thinking that perhaps I needed to update with one more step, I ran brew update httpd but it said that "httpd 2.4.43 already installed."
I'm still pretty new to using brew, and this is my first time creating an Apache server, so any help here would be appreciated. Thanks!
Sorry - easy fix. I neglected to update my .bash_profile to include /usr/local/opt/apache2/bin.
This was clear after I ran which apachectl, and it displayed the default directory for the preinstalled version of Apache - /usr/sbin/apachectl.
I ended up stopping the default version and prevented it from starting again on boot:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Then, started the newly installed version, and it worked fine.

Error during install extensions in Postgresql 9.2

I have tried following:
sudo -u postgres psql <enter>
create extension "uuid-ossp";
but showing error: ERROR: could not access file "$libdir/uuid-ossp": No such file or directory
I have tried: select version(). It's showing my postgresql version PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1, 64-bit
Later tried to install extension adminpack using create extension "adminpack" but it's also throwing error: ERROR: could not open extension control file "/usr/local/share/postgresql/extension/adminpack.control": No such file or directory
I have tried locate uuid-ossp which gave me following result:
/usr/src/postgresql-9.2.4/contrib/uuid-ossp
/usr/src/postgresql-9.2.4/contrib/uuid-ossp/Makefile
/usr/src/postgresql-9.2.4/contrib/uuid-ossp/uuid-ossp--1.0.sql
/usr/src/postgresql-9.2.4/contrib/uuid-ossp/uuid-ossp--unpackaged--1.0.sql
/usr/src/postgresql-9.2.4/contrib/uuid-ossp/uuid-ossp.c
/usr/src/postgresql-9.2.4/contrib/uuid-ossp/uuid-ossp.control
/usr/src/postgresql-9.2.4/doc/src/sgml/uuid-ossp.sgml
/usr/src/postgresql-9.2.4/doc/src/sgml/html/uuid-ossp.html
locate adminpack is giving following result:
/usr/lib/postgresql/9.1/lib/adminpack.so
/usr/share/postgresql/9.1/extension/adminpack--1.0.sql
/usr/share/postgresql/9.1/extension/adminpack.control
/usr/src/postgresql-9.2.4/contrib/adminpack
/usr/src/postgresql-9.2.4/contrib/adminpack/Makefile
/usr/src/postgresql-9.2.4/contrib/adminpack/adminpack--1.0.sql
/usr/src/postgresql-9.2.4/contrib/adminpack/adminpack.c
/usr/src/postgresql-9.2.4/contrib/adminpack/adminpack.control
/usr/src/postgresql-9.2.4/doc/src/sgml/adminpack.sgml
/usr/src/postgresql-9.2.4/doc/src/sgml/html/adminpack.html
At a wild guess, you've downloaded the PostgreSQL 9.2 sources to /usr/src, unpacked it, configured it, compiled and installed it ... but not installed the contribs.
If so, from the PostgreSQL source dir:
cd contrib && make && sudo make install
If you want updated PostgreSQL releases, it's usually better to get them packaged unless you need/want to make source code changes. See http://yum.postgresql.org/, http://apt.postgresql.org/, http://www.postgresql.org/download/, ...
Update: Some of these have dependencies. E.g. for uuid-ossp you must install the ossp-uuid lib first:
apt-get install libossp-uuid-dev
then compile and install contrib/uuid-ossp:
cd contrib/uuid-ossp && make && make install
Check the error output from the make step for more info, and if in doubt, remember, Google. The first error is usually the most important.
For those who come across this and are installing a specific version of Postgresql (e.g. 9.6):
Make sure you install the same version of contrib:
yum install postgresql96-server postgresql96-contrib
When I originally install postgresql96-server using directions from PostgreSQL website, it didn't mention installing contrib, so I installed the wrong version later on - forgetting I didn't use the default version in the CentOS repos.

Missing gcc-4.0 error on pip install twisted in virtual env

I'm trying to use Scrapy inside a virtualenv, which requires installation of twisted as well. I did pip install Scrapy with no problems, but when I try pip install twisted, I'm getting the following error multiple times in the output:
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1
I previously had a similar problem when trying to install python packages on my actual system, which is why I started using virtualenv in the first place. Is this an issue of the python version installed on my environment? This is what I currently have:
Django - 1.5 - active
Python - 2.7.3 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload)
Scrapy - 0.16.4 - active
pip - 1.2.1 - active
setuptools - 0.6c11 - active
wsgiref - 0.1.2 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7)
yolk - 0.4.3 - active
To check which version of gcc I have I typed gcc at the command line and got
i686-apple-darwin11-llvm-gcc-4.2: no input files
I tried export CC=gcc-4.2 before running pip install twisted, and I got:
llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/s8/d0f65gc93nbchdk52g2cg5f80000gn/T//ccWQa7cJ.out
error: command 'gcc-4.2' failed with exit status 255
It sort of looks to me like it's looking for powerpc-apple-darwin11-llvm-gcc-4.2, and what I have above is i686-apple-darwin11-llvm-gcc-4.2--are these different and therefore causing the problem?
To give more background info, I installed Python 2.7 from a Python.org installer a long time ago before upgrading from Snow Leopard straight to Mountain Lion. If I simply type in python at the command line I get
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:32:06)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
So I'm guessing that means I'm using Apple's Python? And it's built with gcc-4.0.1? So if that's the case, shouldn't I not need to do the export CC=gcc-4.2? Or do I need to do that AND switch to the Python.org version of Python? (And if the latter, how do I do that?)
Update: I tried this solution for switching Python versions but it didn't work.
Update: I managed to switch Python versions (outside of my virtualenv) using the sudo port select --set python python27 command, but this didn't solve the problem even though I'm now showing:
Python 2.7.3 (default, Nov 17 2012, 19:54:34)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
when I type python at the commmand line.
Update: I also found this solution to a question that seemed to have almost the exact same issues as I'm having, but I'm already upgraded to XCode 4.6 and definitely have the Command Line Tools installed as described in the aforementioned solution (Preferences>Downloads tab>Install Command Line Tools). I do also have XCode 3.2.6 installed, however--any chance that's causing my problems?
Have you tried CC="$(type -p clang)" pip install twisted? You don't necessarily need to use gcc to compile Twisted's extensions; selecting clang instead might clear up whatever weird problem seems to be infesting your gcc installation.
If that doesn't work, I would suggest un-installing any Python.org versions of Python and then possibly re-installing both the OS and Xcode, since it looks like something might have corrupted your system Python install. I have no idea how references to powerpc stuff have persisted into Mountain Lion, since Lion removed support for ppc.

RubyODBC Cannot allocate SQLHENV

I'm trying to connect to SQL Server on Ubuntu 9.04 using Ruby. I translated and followed all the steps outlined in getting OSX talking to SQL Server from here:
http://toolmantim.com/articles/getting_rails_talking_to_sqlserver_on_osx_via_odbc
Everything is working on the FreeTDS and unixODBC end. I can see and query the database using tsql.
When I try to access the database from Ruby using IRB I get the following error:
DBI::DatabaseError : INTERN (0) [RubyODBC] Cannot allocate SQLHENV
Has anyone run into this and what can I do to solve this?
I started getting this error when I upgraded to Ubuntu 9.10 (Karmic Koala). Your tip regarding installation order of the Ubuntu packages didn't work for me.
It seems the fix was to manually compile ruby-odbc.
wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-dlopen
make
sudo make install
System
Ubuntu 9.10 64 bit
I had to specify the odbc directory in the rubyodbc install
wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-odbc-dir=/usr/lib/odbc --disable-dlopen
make
sudo make install
I had the same problem.
But on Centos 5.5 not Ubuntu
Tried many forums/solutions with no joy.
The error message hints at a missing reference to unixODBC.
Which was setting using LD_LIBRARY_PATH variable.
Found another way to set path, by creating
/etc/ld.so.conf.d/odbc.conf.
add unixODBC location to file ie /usr/local/lib.
Run, sudo ldconfig.
Go fig that I actually got this working after submitting my question. What I ended up doing was uninstall libdbd-odbc-ruby and libdbi-ruby and then reinstalling them by installing libdbi-ruby first and then installing libdbd-odbc-ruby. I guess when I installed them before, something must of messed up.
BTW, following the instructions to recompile Ruby-ODBC on Ubuntu 9.10 (Karmic) required installation of either the libiodbc2-dev or the unixodbc-dev package. When using libiodbc2-dev, I got segmentation faults when my Ruby program tried:
connection.select_all('select top 15 * from log_device_healths')
..but no problem when using unixodbc-dev instead.
Tim Morgan's solution didn't work for me. However I was able to get things working by installing an older version of libodbc-ruby (0.9995) from here:
http://mirrors.kernel.org/ubuntu/pool/universe/libo/libodbc-ruby/libodbc-ruby1.8_0.9995-1_i386.deb
Additional details are available from Carsten Gehling's blog:
http://gehling.dk/2010/02/the-woes-of-libodbc-ruby1-8-and-debian-ubuntu/
Be careful though -- Ubuntu's Update Manager will happily "upgrade" this version of libodbc-ruby to the broken 0.9997-2. I accidentally overwrote the older version this way only to end up back here, trying to figure out how I fixed it last time.
Well, it seems my other answer stopped working for me. This thread helped me to solve the issue in another way, and I wanted to share it here.
sudo gem uninstall ruby-odbc
sudo rm /usr/local/lib/site_ruby/1.8/x86_64-linux/odbc.so
cd /tmp
wget http://mirrors.kernel.org/ubuntu/pool/universe/libo/libodbc-ruby/libodbc-ruby1.8_0.9995-1_amd64.deb
sudo dpkg -i libodbc-ruby1.8_0.9995-1_amd64.deb
If you're not on a 64-bit platform, you'll need to download a different Debian package.
Basically, what solves the problem is installing version 0.9995 of the ruby-odbc Ubuntu package.