I am new to programming (previously only did html/css/design) trying to start learning RoR via the book Simply Rails 2. However I want to start with the most recent versions of Ruby(1.9.2) and Rails (3) so I am forced to get everything configured without the book. I have looked a lot via google and on stackoverflow. When I run rails server
it automatically uses Webrick, but I want to be using Mongrel. I installed the prerelease Mongrel via gem install mongrel --pre
and removed the previous version. I read that in order to get Mongrel to work with rails server
I had to add gem 'mongrel'
to the Gemfile, but I do not know which one I should be adding it to (I tried several but nothing changed). So I decided to look at mongrel documentation via git and learned about mongrel_rails start
when I run that I get this:
C:\Ruby192\shovell>mongrel_rails start
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment... C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:27:in
'block in setup': You have already activated mongrel 1.2.
0.pre2, but your Gemfile requires mongrel 1.1.5. Consider using bundle exec. (Gem::LoadError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'block in each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:17:in
'setup'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler.rb:100:in
'setup'
from C:/Ruby192/shovell/config/boot.rb:8:in '<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from C:/Ruby192/shovell/config/application.rb:1:in '<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from C:/Ruby192/shovell/config/environment.rb:2:in '<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from <internal:lib/rubygems/custom_require>:29:in 'require'
from C:/Rub开发者_JAVA百科y192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:147:in
'rails'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in
'block (2 levels) in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in
'call'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in
'listener'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in
'block in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in
'call'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in
'initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
'new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
'run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/command.rb:210:in
'run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282:in
'<top (required)>'
from C:/Ruby192/bin/mongrel_rails:19:in 'load'
from C:/Ruby192/bin/mongrel_rails:19:in '<main>'`
My best guess is that
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:27:in
'block in setup': You have already activated mongrel 1.2.
0.pre2, but your Gemfile requires mongrel 1.1.5. Consider using bundle exec.
is the key but I have not been able to solve it.
I would appreciate any help so that I can get on to actually learning the language!
EDIT: I was able to get past the above issue thanks to @duddle but now I have another issue...I am getting this error:
C:\Ruby192\shovell>mongrel_rails start
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment... C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in
'req uire': no such file to load -- dispatcher (LoadError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in 'block in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:225:in 'block in load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:591:in 'new_constants_in'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:225:in 'load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in 'require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:148:in 'rails'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in' block (2 levels) in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in 'call'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in 'listener'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in' block in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in 'call'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in 'initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in 'new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in'run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/command.rb:210:in 'run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282:in '<top (required)>'
from C:/Ruby192/bin/mongrel_rails:19:in 'load'
from C:/Ruby192/bin/mongrel_rails:19:in '<main>
My best guess at this point (1am...very tired) is that I am missing a file or something is not named as it should be..maybe i need to use the :require
action in my Gemfile..maybe I just need to sleep on it. Ha.
Again, thanks a ton @duddle for getting me past the first error! Any more help is greatly appreciated!
You have already activated mongrel 1.2. 0.pre2, but your Gemfile requires mongrel 1.1.5. Consider using bundle exec. is the key but I have not been able to solve it.
You were almost there!
gem 'mongrel', '>= 1.2.0.pre2'
The second parameter tells bundler to require a version equal to or greater than 1.2.0.pre2, which you have to use when using Ruby 1.9.2.
The Bundler page provides a nice reference on how to use the Gemfile: http://gembundler.com/gemfile.html
Just in case you didn't figure it out.
I ran gem install 'dispatcher' and added gem 'dispatcher' in the Gemfile of my app. Then everything was fine.
From the small experience I have with ruby, everytime I have a "require -- no such file to load" problem. It is because I am missing a specific gem.
Hth...
add this line to your gem file:
gem 'mongrel', '>= 1.2.0.pre2'
at the command prompt:
run bundle install
start mongrel using this command:
rails server
Hey, I ran into that problem, the solution was quite simple:
Just add the gem 'dispatch'
;-)
The mongrel gem isn’t compatible with Ruby 1.9.2; you’ll have to use gem 'sho-mongrel' in its place.
Try to install it using:
gem install mongrel --pre
It worked for me perfect!!!
精彩评论