33

When using ruby 2.1.0 (or 2.1.1) and I type rails g nothing happens. It simply hangs. But when I change to 1.9.3, using rvm use 1.9.3 it works as expected.

How can I debug this? What might be causing this command to hang, only on ruby > 2.0.0?

I have tried reinstalling both rails and ruby!

subZero
  • 5,056
  • 6
  • 31
  • 51
  • Are other ruby scripts impacted or only rails? Have you tried reinstalling ruby ? – Intrepidd Apr 18 '14 at 15:46
  • Yes, I have tried reinstalling both rails and ruby! It seems like it only affects rails – subZero Apr 18 '14 at 15:47
  • what about use 2.1 ruby again, "rvm use 1.9.3 && rvm use 2.1.0", rails gem exists? – Alexander Randa Apr 18 '14 at 16:54
  • Yeah, they do. Thank you for the reply. Any other ideas on how I can debug? – subZero Apr 19 '14 at 12:09
  • Same with me, I do not have ruby 1.9.3 installed, only 2.1.0. Do I have to install the lower version (again) and then "rvm use 1.9.3 && rvm use 2.1.0?btw I deleted 1.9.3 after installing 2.1.0 – Timo Jul 01 '14 at 11:02

2 Answers2

185

Have you tried to run:

spring stop

rails generate hangs may because spring is already running.

see https://github.com/rails/spring/issues/265

lingceng
  • 2,415
  • 1
  • 18
  • 19
2

I tried all of this and it didn't work for me. Turns out that I had a bad rails file in my /bin folder.

This is what I had:

#!/usr/bin/env ruby
begin
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rails', 'rails')

And I just recreated a new rails app and copied the proper one:

#!/usr/bin/env ruby
begin
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

This worked for me!

neofetter
  • 3,004
  • 2
  • 26
  • 26