Rails Server broken after PostgreSQL download - ruby-on-rails

Operating System I am using is Mac OSX Mountain Lion.
First I will give some back story on how this cluster F started. I am going through a Ruby on Rails Web development book. I want to use PostgreSQL as my server. Before today I was using sqlite3. I downloaded PostgreSQL 9.1 from there website. I used the DMG installer. Once I was done with the install process it asked me to re-boot because of some sort of memory problem, I did that and it installed without error.
The problem started when I tried to use the "Rails Server" command in the terminal. This is what I got (I tried to strip out the unimportant stuff which would clutter everything up)
/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: /usr/lib/libcrypto.dylib (LoadError)
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8 - /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle
...
from /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/commands.rb:50:in
I have read through the out put and I have done a lot of Google searching, and what I have found is that it's a problem with which version of libcrypto the server is fetching. Or something about the libssl. I have gone through the solutions on google and nothing seems to be working. Hopefully someone has had the same problem I have, and can help me.
Thanks in advance! -Chris

I really recommend you to use Homebrew to install postrgresql. It helps you to install all proper dependencies for version which correctly works with rails.
$ brew install postgresql
Do not forget to follow after install instructions from homebrew

Are you sure you installed PostgreSQL server/rubygem successfully? From the stack trace I think there's a problem about it.
If your PostgreSQL server/rubygem are working well, then switch another webserver, mongrel/thin are both OK, both have better performance than the default rails server(webrick) and easy to use.

Related

Rake db:create fails on Library not loaded

I was running PostgreSQL 9.1, installed from Postgres (/Library/PostgreSQL/9.1) - ie not homebrew etc and on Mac OSX Leopard.
I upgraded to Snow Leopard and then immediately to Mountain Lion and had a mass of problems with gems failing to build etc, but got them fixed
Rails server crashed on startup with pg issues & I tried everything I could find but could not fix the prob - fixes included links etc, which may still persist (hence this background info might inform the solution)
I uninstalled postgresql 9.1 and installed Postgres App
Now on rake db:create I get the following:
rake aborted!
dlopen(/Users/mitch/.rvm/gems/ruby-1.9.2-p320#tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle, 9): Library not loaded: #loader_path/../lib/libpq.5.dylib
Referenced from: /Users/mitch/.rvm/gems/ruby-1.9.2-p320#tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle
Reason: no suitable image found. Did find:
/usr/local/lib/libpq.5.dylib: mach-o, but wrong architecture - /Users/mitch/.rvm/gems/ruby-1.9.2-p320#tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle
I'm running rvm (as u can see) and after the OS upgrade created a new gemset and installed Ruby
I've changed my path to reflect the advice of Postgresql App, after the OS upgrade I installed Xcode 5 and the command line tools as advised and I think my database.yaml file is ok
I suspect the problem might be connected with sym-links made earlier in the process, but I'm stuck to find the solution
Sounds like something has gone wrong in your Ruby installation. Try reinstalling Ruby Enterprise Edition via RVM:
rvm reinstall ree
I was experiencing the same issue with a different version of libpq. What I ended up doing is creating a link to the correct file:
sudo ln -s /Applications/Postgres93.app/Contents/MacOS/lib/libpq.5.6.dylib /usr/local/lib/
My previous answer was deleted as it wasn't originally an answer, just a confirmation of a similar issue. Hope this helps!
In the end I think this was tied up with the fact that Mountain Lion ships with Postgresql rather than MySQL as per previous OSX versions.
I couldn't make sense of the Postgres App, so I uninstalled it and also uninstalled the version of Postgresql that shipped with ML and then did a Homebrew install of the latest version of Postgresql (which places it in a different place than if you install it direct from the Postgresql site).
This seemed to straighten everything up

Trying to get Ruby/Rails installed on OSX Mountain Lion

This is my first question please be nice.
I've been trying to get my hands dirty with ruby/rails for a small coding project. I have Mountain Lion, and have been trying to use various techniques i've found on stackoverflow, and across the interwebs. It's not going so great! Nothing works of course. I have the system version of Ruby (1.8.7) as of now, and a bunch of broken junk from trying and failing to install Ruby!
When I install Rails via gem install, it sat for awhile... I finally learned to use -V, and noticed everything was returning back 302, and this takes forever, and finally it installs -- I get this output when I try to run rails -v
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:230:in `activate': can't activate rack (~> 1.4.5, runtime) for ["actionpack-3.2.13", "railties-3.2.13"], already activated rack-1.5.2 for ["rack-ssl-1.3.3", "railties-3.2.13"] (Gem::LoadError)
It looks like some dependencies are broken? Anyhow I'm now trying to use RVM now to get another version of ruby and setup grails with brew, This is telling me that I need a newer version of ruby to install anything pretty much?? Here is the output.
rvm install 1.9.2-head
Installing requirements for osx, might require sudo password.
Skipping brew update make sure your formulas are up to date.
Cowardly refusing to continue, please read 'rvm autolibs'.
To proceed rvm requires a ruby-1.9|ruby-2 compatible ruby is installed.
We attempted to install ruby automatically but it failed.
Please install it manually (or a compatible alternative) to proceed.
-- I am getting os frustrated here, please throw me a bone and help me out --- If I have to have to I'll setup a linux vm just to get rails running -- yet I prefer working on my mac.
Please any advice?? I just want a working version of Rails 3 on my Mac this is allThanks in advance
Please go through www.railsinstaller.org for detailed installation and setup process. This guide should answer all of your questions.
Have you tried this tutorial http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/
The tutorial includes all the errors you may come across during the installation.
According to this tutorial Ruby on Rail comes with the mac out of the box.
Have you tried JewelryBox? It provides a painless install method for rvm and a great little gui that helps you monitor the size of your gem sets, and installs of ruby. Along with helpful reminders to upgrade rvm. I resisted at first using it, because using a GUI made me feel like a noob, but it really is a great little tool, that makes for super easy installs of ruby, and rvm, and consequently rails.
http://jewelrybox.unfiniti.com/

RSpec stopped working after upgrading to OSX Lion

dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/identify
Reason: image not found
Does anyone have a solution? Would upgrading Xcode to 4.1 help?
I'd recommend installing the latest XCode, 4.1, from the App Store before you do anything else, so as to get the latest build tools and dev libraries.
You'll likely need to recompile any Gems with native bindings (which it looks like you have, since something is looking for OpenCL, likely not RSPec itself).
To recompile all your gems run:
gem pristine --all
dydl errors are commonly associated with database drivers/bindings. Try re-installing your database if neither of the above work.
Your /opt/local/bin/identify is probably ImageMagick’s identify.
You probably need to rebuild your installation of ImageMagick. Based on the pathname (/opt/local/), you probably installed it as a part of MacPorts.
You should probably follow the instructions for Migrating a MacPorts install to a new major OS version or CPU architecture: install new Xcode, install latest MacPorts base, record installed ports, remove ports, reinstall ports.
Unfortunately, MacPorts’ bug #30322 indicates that the ImageMagick port may not yet build properly under Lion (found via MacPorts’ Lion Problems page).
I had a problem similar to this after a clean install of Lion, with Xcode 4.1 installed (both from the Mac App Store).
What eventually fixed it was running sudo gem install rspec -v 2.6.0. The actual problem (for me, your mileage may vary) was that the script stub wasn't being installed in /usr/bin, which meant the OS couldn't find RSpec without a full path spec.

Installing PostgreSQL on OSX for Rails development

I've spent several hours over the past few days trying to get PostgreSQL to play nice with RoR on my Mac.
I've followed several tutorials using several different methods such as installing PostgreSQL manually and installing from various 1-click installers
However the all the different methods I tried failed on the last step of installing the pg gem. Very frustrating!
Does anyone here have a tried and tested tutorial for getting this done? (Or would you like to write some instructions here...?)
My environment is this: Macbook running OSX 10.6, PostgreSQL 8.4.1 server
I think I've managed to find a way that works. I'm borrowing heavily from this great post1, but since they are installing a bunch of other stuff at the same time I'm going to write out what I did here for people who are just looking for the PostgreSQL install answer.
1 Editor's note: Link seemed dead when I tried. Is this the one? http://blog.blackwhale.at/?p=175#PostgreSQL Please fix if it is.
Download PostgreSQL for Mac and download the ‘Postgres.app’ installer.
Create a user for your rails development (keep in mind that if you're sharing an application during development you'll probably want the same user between all members your dev team in order to avoid headaches)
sudo -u postgres /Library/PostgreSQL8/bin/createuser
Enter your Mac OS X system user name as role name, and make it a superuser.
Install the pg gem so Rails can talk to PostgreSQL
sudo env PATH=/Library/PostgreSQL8/bin:$PATH gem install pg
Configure your rails app to talk to PostgreSQL. You can either create a new application with:
rails *appname* -d postgresql (for Rails 3 -> rails new *appname* -d postgresql)
Or for an existing app, modify your database.yml file.
This worked for me without any hiccups. If anyone else tries using this method I'd be interested to hear some feedback on how it went for you.
On a 64-bit Mac (Snow Leopard with Core 2 Duo or newer) I had to compile PostgreSQL from source, as rails kept complaining that:
*** Your PostgreSQL installation doesn't seem to have an architecture in common
with the running ruby interpreter (["ppc", "i386", "x86_64"] vs. [])
The architecture mismatch was probably bc I'd compiled rails from source, which defaulted to 64-bit. The binary installer on postgresql.org seemed only a 32-bit version. Setting ARCHFLAGS didn't fix this for me.
Anyhow, if you download the [source][1] from postgresql.org and follow the instructions in the INSTALL file, it's fairly straightforward. You don't have to create a new user if you use your own account. I did have to create the sysctl.conf file to expand shared memory - just google 'postgresql os x sysctl.conf'
Old question, but still maybe i can help someone with this (rather simple) solution:
gem install pg -- --with-opt-include=/opt/local/include/postgresql84/ --with-opt-lib=/opt/local/lib/postgresql84/
Download and Install MacPorts
fire up terminal
sudo port install ruby postgresql83-server rb-postgres rb-gems rb-rails
Thanks to Ganesh for the good awnser, my sudo url looked a bit diffirent :) here is what I havesudo -u postgres /Library/PostgreSQL/9.2/bin/createuser
Ryan Bate's Railscast on PostgreSQL walks you through setting it up on a Mac with Homebrew. Very easy, worked for me on OSX 10.6.8.

One-Click install for Ruby/Rails/SQLite?

I'm used to the One-Click install local environments of MAMP. Is there a Ruby equivalent... a download that you run and instantly get the most current versions of Ruby, Rails, SQLite running locally?
I'm using a Mac, running Leopard, and am aware that all of the aforementioned technologies ship with Leopard (except maybe SQLite). The books that I have reference newer versions and the last thing I need is to try to retrofit a tutorial to work with my version.
And one more less important question: What are "Gems" and is that something that I need to make sure is fully updated too?
Installation is pretty confusing when you first start with Rails! Even though a lot of what you need is already installed if you are using Mac, personally I found it really hard to find come concise information on how to best go about setting things up.
Since I didn't want anyone else to go through the headaches that I had when configuring their Mac development environment, I've written a 7 step guide to installing Ruby on Rails, MySQL, Apache with PHP, and phpMyAdmin on OSX Leopard. In short, everything you should need to get developing locally on your Mac!
Here's the link:
http://waavoo.com/2009/7-step-guide-installing-ruby-on-rails-mysql-apache-php-phpmyadmin-intel-mac-os-x-leopard/
Hope that helps!
Take a look at FiveRuns Install. It's a free Ruby on Rails stack that you can download.
RubyGems is the Ruby standard for publishing and managing third party libraries. Check out the User Guide.
Have fun!
I have no idea what mac os are you in but Leopard (10.5.x) already have ruby installed, all you need is to updated the gems using
gem update rails
in your command line.
if you're on Tiger (10.4.x) the installation is broken, and please follow this link.
You should also have a look at Phusion Passenger - this, along with the prefpane, allows you to have apache VirtualHosts set up the easy way.
Current versions of Rails are designed to work (for development) without needing an AMP -style stack, by using SQLite and a small Ruby Web server, so if you will only be doing Rails development you don't need to set up a stack - you can just type "rails" and it will work.
BUT the versions of RubyGems and Rails shipped with Leopard are now outdated, though, so you'll need to upgrade these before you go too far. There's an article that I wrote on setting up a Mac for development here, but the minimum commands go like this:
sudo gem install rubygems-update
sudo update_rubygems
sudo update_rubygems (yep, twice)
sudo gem update --system
These get RubyGems up to the current release, so that you can upgrade Rails safely. To do that, type:
gem update rails
The last command doesn't have sudo, because if you omit it, current versions of RubyGems will install a clean copy of the gems into your home directory, leaving the system versions untouched.
Finally, amend the .profile file in your home directory, so that the line with PATH in it says:
export PATH=$HOME/.gem/ruby/1.8/bin:$PATH
Close up any terminal windows for this to take effect. The utilities provided by the gem packages in your home directory will now have precedence over the system versions.
This means that you can type "rails" and the latest version will run, but you haven't messed with any of the software provided by Apple (apart from the system copy of RubyGems).
To upgrade your private copy of Rails whenever a new version comes along in future it's just this again:
gem update rails
just refer this....
http://wiki.rubyonrails.org/getting-started/installation/windows#installing_ruby_on_rails_on_windows
BitNami RubyStack is exactly what you are looking for http://bitnami.org/stack/rubystack

Resources