Rails s doesn't boot mongrel by default - ruby-on-rails

I'm developing rails app on
Mac OSX 10.7
RVM
Ruby 1.8.7
Rails 3.2.0
But, when I run rails s, Webrick will be booted by default.
Note that
I can boot into Mongrel by rails s mongrel. But as I start and stop the server for like every few minutes, it will be great if I can avoid typing 8 extra characters. And yes, I can do linux command to run specific previous command (something like !200). But, I'd be glad to solve this problem
This project used to develop with Rails 311rc2 and Ruby 1.9.3 (By previous developer) but with a lot of problems. So, I decided to switch to Ruby 1.8.7 and Rails 3.2.0
I need to use Ruby 1.8.7 as it's the same version as my company production server and all other projects/developers are using 1.8.7 too
I've been looking for a solution for almost two hours, visit a lot of site, tried all suggestion I found. But, none of them works
Here's my gem file
group :development do
gem 'mongrel', '>= 1.2.0.pre2'
gem 'ruby-debug'
end
What I tried,
1. uninstall and reinstall rvm 1.8.7
2. remove and reinstall gemset
3. remove all gem and run bundle install
Do you have any suggestion ?

It's not rails related but Rack related.
Before, rack by default launch a mongrel server if you have mongrel install. Now, this behavior change in prior of Thin. So if you have thin install, rack launch it instead of webrick.
If you want allways launch by Mongrel. specify it.

Related

Can I downgrade from rails 5 to rails 4.2.5 on Ubuntu VPS

Ok this may sound stupid, but I was setting up a VPS to deploy an rails app to... the app is built with rails 4.2.5.
On the server I accidentally installed rails -v 5. And after deploying the app to the server I always get this error: We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly. when I try to visit the site.
Since this is a Rails error I figured that it is due to the mismatched versions of (rails 4.2.5) at my computer and (rails 5) on the server side.
So my question is if it's possible to uninstall rails 5 and install 4.2.5 instead on the VPS server?
EDIT
Rails 5 was installed gem install railsand then rbenv rehash
Because I'm new to this all and the learning curve is steep I feel safer asking here instead of messing it up by my self :)
Since you installed rails using gem install rails, you can run gem uninstall railsand then gem install rails -v 4.2.5.
I recommend you to use a Gemfile. In it you can specify the version of the gems that you want to use and bundle install will handle the installation.

Can't boot WEBrick, the folder for Rails gem is empty

I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.

Passenger stand alone uses wrong ruby version?

Hello im using rails 4 with rvm - ruby verison 2.0.
But when i try to start passenger (stand alone) im getting syntax-errors.
It tells me:
Ruby interpreter command
/usr/bin/ruby1.8
How can i change it to the rvm 2.0 version?
I had the same problem: passenger standalone uses nginx, and after upgrading my app to use ruby 2.1.1 (specified in the .ruby-version), I saw similar errors.
On my production server, I know where the nginx configuration lives, so I could fix the path to the ruby interpreter.
However on the standalone setup I couldn't find it in less a minute, so I did a gem uninstall passenger followed by gem install passenger to have it recompile nginx.
Now it works, at least until the next ruby interpreter bump.
you need to use ruby first:
rvm use ruby
it might display additional instructions - make sure to read them

Heroku gets error with Ruby Mongrel gem

Can't quite find the answer for my error in related posts.
I'm working my way through the on-line version of the Ruby on Rails Tutorial, Chapter 2
http://ruby.railstutorial.org/chapters/a-demo-app#top
and I'm near the bottom where I've created a small 2-table database and committed it to git. But it fails when I try to deploy with 'git push heroku master'. The same command worked previously before I added the tables to the app (and before I got Mongrel to work on the demo_app, I think).
My bundle includes Ruby 1.8.7, Mongrel 1.1.5 and sqlite3 1.3.3. I'm getting the line:
Installing mongrel (1.1.5) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions':ERROR: Failed to build gem native extension. (Gem:Installer::ExtensionBuildError).
How do I get around this problem? Can Heroku handle Mongrel at all? Or is it due to having a sqlite3 database? Why does the error mention Ruby1.9.2 when that's not in my bundle?
You don't need to use mongrel at all, and should simply remove it from your Gemfile. Whenever you see a reference to starting mongrel in your tutorial, just use ./script/server instead (or rails server if you're on Rails 3). It will run WebBrick, and that's good enough for development work.
If you really want to retain mongrel for local use you can group it as follows in Gemfile.
group :development do
gem "mongrel"
end
Note that you will likely still have to tell Heroku to not bundle your development gems or you'll run into the same error. If you're on the Cedar stack, then just get rid of the mongrel gem entirely.

Passenger with Nginx cannot find rails 2.3.8 gem

I have been trying to setup nginx with passenger for a few days now and keep running into problems. When I go to my Rails application with my browser it says: Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
If I type gem list in my terminal it shows: rails (3.0.0, 2.3.8, 2.3.5)
What is funny is that passenger will find my ruby gems just fine when I use it with Apache on the same machine! But I would like to experiment with nginx because Apache is not doing what I want.
The machine is Ubuntu 10.04 Server
which ruby Shows: /usr/local/bin/ruby (REE)
These are the passenger directives in the nginx.conf:
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15;
passenger_ruby /usr/local/bin/ruby;
#Nik Rishav is correct in that you have to be careful when installing Ruby Enterprise Edition (REE) along side the system Ruby. Installing REE incorrectly can cause some very strange things to happen.
While Rails 3.0 could be the cause of your issues, my gut tells me your real issue is one missed step when installing REE. But, just-in-case this doesn't work, a quick Google search will show you any number of good tutorials showing you how to host a Rails app with Phusion Passenger for Nginx. Well, let's give it a go, shall we!
REE runs fine alongside system Ruby, but you have to install it into its own directory. For example:
/opt/ruby-enterprise-X.X.X/bin/ruby
Your other option is to only install REE, but this might not be an option for you. I suspect that when Nginx runs, it does find REE as you have specified it. Did you install Passenger for Nginx from the REE stack?
/opt/ruby-enterprise-X.X.X/bin/passenger-install-apache2-module
If you haven't, you might want to look into that. I'll assume you did.
From your description, it doesn't look like you have told REE where to find your gems. To do this, you need to set REE as the default Ruby Interpreter. To do this, add an entry to the file /etc/environment. On Ubuntu, the directory is /etc/environment. Add REE's bin directory to the PATH environment variable, like this:
PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin"
Placing REE first in the PATH will set it as the default Ruby interpreter.
Then restart Nginx, like so:
sudo /etc/init.d/nginx restart
Hopefully this helps. I've had my share of deployment issues and it truly can be frustrating. Wouldn't wish it on anyone...Good luck!
As a check, are you sure your passenger is installed in the correct version of ruby. basically
Both the rubies have separate gems meaning you have to install the other in one..
Check in the /usr/local/lib/ruby/gems/1.8/gems Directory to see if rails 2.3.8 is present. You need to install it in the this ruby.
Both rubies will have separate gem bin files for installation..
possibly /usr/bin/gem is for the system ruby
and /usr/local/bin/gem is for your installation of REE

Resources