CTRL+C to Webbrick server ignored - ruby-on-rails

In the past, I could exit my rails application launched using webbrick using CtrlC. At some point in development, this functionality broke ( CtrlC does nothing now). I'm lead to believe this was caused by changes in one of my gem dependencies, as the problem is also present when checking out a really old version of the application, using the current gemset.
My question is: how can I fix this problem, or at least find the out what is causing it?

For windows users, this was broken in more recent builds of rails (3.2+). Try using
ruby script\rails server
instead. More details here.

Try Ctrl+Break. It should work.

I had the same issue with an application. It would seem that the issue is not with the authlogic gem but with the ":git" option. My entry causing webrick & mongrel to stop responding to Ctrl+C was
gem 'globalize3', :git => 'git://github.com/refinerycms/globalize3.git'

Interesting experience (and good workaround for the next weeks):
If you are under Ubuntu and use Guake for quick terminal access, you can launch
rails s
there. Ctrl + C reproducibly works there for me and stops the server.
Hope I could help! :)

Seemed to have solved my own problem. Authlogic
gem "authlogic", :git => 'http://github.com/binarylogic/authlogic.git'
appears to be the root cause of this problem. I've opened an issue here

I have been experiencing similar issues, specifically on Ubuntu 11.04 (things were fine on 10.04). I've created another question that was more specific to my particular setup, but it sounds like there is a lot of crossover, so people might be interested in reading it as well:
Can't stop WEBrick 1.3.1 with ctrl-c on Ubuntu 11.04

I was experiencing this problem on Ubuntu 11.04, Ruby 1.9.2p290. This fixed it for me:
Remove all existing Ruby & Ruby-related packages
Install RVM
Install Ruby 1.9.3
$ rvm install 1.9.3
$ rvm use 1.9.3
Make sure it works
$ ruby -v
ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-linux]
Install all your gems, etc...

why not trap()ing signals?
http://theriyanto.wordpress.com/2006/04/05/develop-a-simple-webserver-using-webrick/

Related

Controlling Ruby Version

Forgive me if there's a duplicate, but I'm honestly not sure what to search for. I'm working on a project with Ruby on Rails, and I get this message when doing anything related (ie: rake, rails, rspec, etc.):
Your Ruby version is 2.1.5, but your Gemfile specified 2.2.3
Now, I've installed RVM and I can fix this issue by issuing the command
bash --login
edit for clarity
running the above command does use Ruby 2.2.3 to execute the commands.
/edit
Then those given commands work. What I would like to do is to remove version 2.1.5 entirely -- leaving only 2.2.3. I've gone about this so many different ways, but Ruby is pretty foreign territory to me so I'm not sure what to do about this. I'm sure I have at least three installations of Ruby on my machine - possibly two duplicates of the two versions I know I have - and I would like only one version and to avoid needing to enter the bash --login command in order to run my project.
I'm running Ubuntu 15.10 and have at least some knowledge of how this works. If somebody could walk me through removing everything related to Ruby & Ruby on Rails, then installing only Ruby 2.2.3 and Rails 4.2.4, I would greatly appreciate that. Let me know if this isn't the proper exchange for this question. It didn't quite seem to fit into Ubuntu or Sysadmin.
What you need to do is not try to remove ruby 2.1.5.
You have RVM, so, use that to get the new version you want.
After this, you now have two options:
1) make the newly installed version the global default version on your machine,
or
2) create a gemset for your project, and specify the needed ruby version for the project.
Either of these will fix your problem.
You have to modify the Gemfile.
http://bundler.io/v1.3/gemfile_ruby.html

Getting Rails 1.1.2 server running on Mac script/server

So I'm a rails developer familiar with Rails 3 and 4. I'm taking on a Rails 1.1.2 project, and the first problem I'm having is getting the server running.
I'd really love some help figuring out what I'm missing setting up the environment. When I run script/server, I get:
-bash: script/server: /Users/michael/.rvm/gems/ruby-1.9.3-p545: bad interpreter: Permission denied
This is after noting that at the top of the script/server file, there's an opportunity to define the location of the ruby install with a ruby comment:
#!/Users/michael/.rvm/gems/ruby-1.9.3-p545
At least, this is how I understand it. What should this comment point to? Does this look correct? I've installed ruby 1.9.3 using rvm and installed rails V 1.1.2 through sudo gem install rails. Everything seemed to work fine.
Is this some kind of bash permissions issue? I really don't understand what's going on. Any help would be appreciated!
I believe a rails project that old will require Ruby 1.8.7, so you should start with an older version of Ruby just to be sure. Once you get it running with the older ruby version, you can try 1.9 again, but trying it with 1.8.7 should help you out a bit. Your shebang should be able to do this though:
#!/usr/bin/env ruby
It needs the path of the ruby interpreter, which can be obtained dynamically via the above line.

Error in checking rails version on ubuntu 10.04

I installed ruby and rails on my ubuntu 10.04 system.While checking rails version it gave me error like this below.
$ rails -v
getopt: invalid option -- 'v'
Terminating...
What is wrong with the rails?Thanks in advance.
I installed rails using gem.
I followed the instructions from https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
check this link http://community.activestate.com/faq/running-rails-debian
Turns out rails -v only works in version 2.3.x and upwards. I suspect you have an older version that is being used even while a newer gem is available, which is what was happening in my system.
To solve I deleted the following:
usr/share/rails
usr/bin/rails - this is the generator script that keeps screwing up
Uninstall Rails with 'sudo gem uninstall rails' and reinstall again.
That solved my problem.
Warning it might break your system and possibly cause weather change patterns in or around Southeast Asia. Don't say I didn't warn you.

Installing Ruby Version Manager AFTER ruby on rails installation

This might be a paranoid question, but am I likely to break anything in my ruby on rails app if I install RVM AFTER having installed rails?
Thanks in advance for any peace of mind you can offer me :P
Your App will be fine - but after installing RVM it will take some configuration get everything running back the way it was. This has nothing to do with your app, but with your environment. If you follow the installation instructions EXACTLY then it will not be too difficult.
If you are planning to do this on a production server then be prepared for some downtime.

Upgrading Ruby broke Rails?

So, I upgraded Ruby to 1.8.7 to make a particular gem work. Hooray, it works now! But...now rails doesn't. I tried reinstalling rails through gem, but that hasn't helped, either. Rake is no longer recognized by my windows box as a valid command, and I can't even start the server without a whole string of errors.
My only thought is that maybe I shouldn't have copied my gems file over (a tutorial mentioned it as the only way to save my gems on windows with an upgrade). I'm gonna try reinstalling 1.8.7 without changing anything, and reinstalling everything as needed.
Edit: Okay, just plain 1.8.7 does work, but it's frustrating to have to reinstall all my gems by hand... Is there any better solution, in Windows?
You may have to uninstall the old version first or use something like RVM to manage your multiple versions. I've always run into problems trying to upgrade directly on a windows machine (rake and rails not working basically).
Edit: Looks like even with RVM you have to install gems individually for each version (a good thing), but you can also export and import gem sets. That might be your best bet, short of scripting a solution yourself.
That is normal: each ruby environment has their own set of gems. That might not seem intuitive, but i guess it has something to do with the possible differences in ruby versions and the fact that gems are "installed" and compiled if needed.
I have a script that installs all my needed gems on windows. On windows rvm does not work, but there is an alternative called pik. I have written a blogpost about this process, which also contains a small bat-file i use that will install the most commonly used gems automatically.

Resources