How run a RoR application using a custom Ruby installation? - ruby

On my Mac Os running Snow Leopard 10.6.5 I successfully installed Ruby 1.9.2 performing these steps so that, in the Terminal, I have these results:
$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0]
$ which ruby
/usr/local/bin/ruby
Now, when I run my RoR application and I get an error (in my case a "SocketError"), I have the following RoR "Framework Trace":
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:560:in `initialize'
...
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:772:in `get'
activeresource (3.0.1) lib/active_resource/connection.rb:112:in `send'
...
that means my RoR application is still running on the previous version of Ruby (v1.8.7)!!!
How can I run my RoR application using my new Ruby installation (v 1.9.2)?
P.S. I: all my RoR applications are located in /usr/< my_mac_account_name >/Sites directory
P.S. II: I am using Phusion Passenger

Not a solution for this particular problem, but you should really really use RVM to manage your Ruby installations. That's the easiest way to be sure you're using X version of Ruby (and thus it's related gems). Then you can switch between versions like this:
rvm use 1.9.2 #begin using Ruby 1.9.2

I suspect that your phusion passenger was built against the system Ruby, not the one you've got in /usr/local. Rebuild phusion Passenger but modify the path in the environment you're building phusion in.
On a linux:
export PATH=/usr/local/bin:$PATH
Not precisely sure of the PATH settings for Mac machines.
Reference:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#_preparation_gem_and_source_tarball_only

Related

Phusion Passenger Standalone: How to pass a command line flag to ruby?

As part of a performance analysis, I'd like to run my rails app with several different rubies. All of them have the gem passenger (v5) installed and are able to run passenger start.
The question: How can I pass a flag (like --1.8) to my ruby interpreter? I'm using the version manager rbenv, but when I'm running
ruby --1.8 -S passenger start
using the interpreter jruby-1.7.27, the flag is non-persistant i.e. jruby does not run in the 1.8 compatibility mode.
I found that you can set an environment variable, which also applies to the instantiated passenger server:
env JRUBY_OPTS=--1.8 ruby -S passenger start
works like a charm.
See the JRuby FAQ for further details.

Ruby on rails 4.1.6 + Capistrano 3: purge gems on deployment server

Hy guys,
I have a server with apache, passenger 4.0.50, ruby 2.1.2 (started with 1.9.3), RVM and dozen of ruby on rails 4.1.x apps.
RVM is used only to manage ruby versions.
Follows the bundler configuration for each app:
BUNDLE_FROZEN: '1'
BUNDLE_PATH: "/PATH/TO/DEPLOYED/APP/shared/bundle"
BUNDLE_WITHOUT: development:test
BUNDLE_DISABLE_SHARED_GEMS: '1'
In order to save disk space (a lot of space) I would like to remove old gems of each application using bundle clean
The idea is to keep 2 releases (capistrano) and to run the command before a new deploy in order to keep gems for the last release.
The problem is that gems installed whit ruby 1.9.3 are not removed.
Can you please confirm that:
Gems for ruby 2.1.2 are installed in /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/2.1.0/gems
Gems for ruby 1.9.3 are installed in /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/1.9.1/gems
I can remove directory /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/1.9.1/gems since I'm not using ruby 1.9 anymore
Many thanks in advance for your help.
Mauro
You dont use ruby 1.9.x anymore, so just remove the gems directory for it.

Ruby on rails installer issue in windows 7 pc

I just have installed in my windows machine form railsinstaller.org.
Now earlier I have already installed in my machine Ruby2.0. So when I am trying to run the below command from the command prompt as mentioned here:
rails s
getting error as :
C:/Ruby200/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not f
nd 'railties' (>= 0) among 8 total gem(s) (Gem::LoadError)
from C:/Ruby200/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `g
m'
from C:/RailsInstaller/Ruby1.9.3/bin/rails:22:in `<main>'
Now if I uninstall the Ruby2.0 things are set. But I want also to be workable in my pc the latest version of Ruby,so that I can run my practice ruby programs as I could earlier. - Please instruct me ,so that I can run my Rails and only ruby programs from my Sublime Text 2 editor without impact.
Try using the installer from this site: http://rubyinstaller.org/
After it installs, install ruby by opening the command prompt and typing:
gem install rails
that should install rails and its dependancies. From there you can just run the rails command and create projects like usual.
Perhaps you should have a look at https://github.com/vertiginous/pik/ to manage different ruby versions. I think, that the main problem you got is simply, that the PATH-settings for both rails versions (1.9.3 used in railsinstaller and 2.0) are interfering.

Failing deploy with RVM + unicorn

I'm trying to setup a Sinatra App with unicorn.
After following this example
and adjusting it to my needs, I've gotten this error:
<my_path_name>/vendor/bundle/ruby/1.9.1/gems/kgio-2.8.0/lib/kgio.rb:21:in 'require': cannot load such file -- kgio_ext (LoadError)
I'm using rvm 1.18.5, ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux] and the latest release of unicorn 4.5.0 which pulls kgio 2.8.0
The OS is Red Hat Enterprise Linux Server release 5.6.
I've also tried with ruby-1.9.3-p125.
Sounds like a similar problem here, maybe try one of those ideas.
Did the gem install go smoothly?

Error: Rack app won't run -- bundler/setup

I'm completely new to Ruby (and RoR) and I'm trying to set up a local environment to help work on a site. Ideally, I would work on it locally, and then commit the changes to github and push it further down the pipeline from there.
I'm on a brand new Macbook Pro running OSX Lion.
I have had much trouble trying to get it work:
Installed Xcode Command Line Tools and RVM couldn't install latest version of ruby because it failed to compile with LLVM (Lion default compiler)
compiled ruby using a special flag it asked me to use (forgot what it was), but then was having trouble with Postgres and Pow
Tried installing a standalone GCC to compile ruby correctly thinking it may solve the problem. Pow still gave me errors.
I have tried removing and installing everything I could think of, and still nothing. I stress: I'm a noob.
I finally found a script called railsready that sets up ruby and RoR for you (https://github.com/joshfng/railsready) which failed to recognize Xcode since Lion installs it into Applications (the script checked for it by looking for an Xcode .plist file in Library/Developer). The author helped be out by updating the code to look for gcc instead and it tried installing but failed because it couldn't write to my .bash_profile. I removed it and tried it again, and it worked.
I installed Pow so I can have it run on a custom domain (website.dev) and have multiple apps under different domains. Now it's giving me this error and I have no idea what it means or how to go about it.
I would really appreciate any help. Most ruby guys I talk to have no idea what this is about, and why Lion is so much trouble to set up on. They are on older (Snow Leopard) machines.
The Error
Your Rack app raised an exception when Pow tried to run it.
LoadError: no such file to load -- bundler/setup
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
~/Github/letsordernow/config/boot.rb:6
~/Github/letsordernow/config/application.rb:1:in `require'
~/Github/letsordernow/config/application.rb:1
~/Github/letsordernow/config/environment.rb:2:in `require'
~/Github/letsordernow/config/environment.rb:2
~/Github/letsordernow/config.ru:3:in `require'
~/Github/letsordernow/config.ru:3
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/Github/letsordernow/config.ru:1:in `new'
~/Github/letsordernow/config.ru:1
Welcome to Ruby On Rails. :)
You're going to love the new Rails.app Kickstarter project by Yehuda Katz:
http://www.kickstarter.com/projects/1397300529/railsapp
My advice for now:
Standalone GCC is good. You're doing this right.
To use RVM with Lion and non-LLVM, read about compiling Ruby with clang: Can't install Ruby under Lion with RVM – GCC issues
In each of your Rails projects, run this which may clean up your Pow issues:
bundle install
Make sure each of your projects has a .rvmrc file pointing to the correct ruby version and gemset.
My two cents is to try to get up and running without RVM and Pow to start. These aren't needed and they have quirks with paths and glitches (IMHO). I personally prefer to use bundler to manage gemsets, and the rbenv tool and ruby-build tool for managing Ruby versions. See https://github.com/sstephenson/rbenv
Pow is nifty but tricky. It has a history of quirky setup (IMHO). My two cents is to get up and running with webrick first (i.e. make sure you can do "rails s" to start a local server) and then I personally like Apache and Passenger (or Thin). For Pow help on quirky setup see https://github.com/37signals/pow/issues/119

Resources