Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"rails generate" not working

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!

like image 463
subZero Avatar asked Apr 18 '14 15:04

subZero


2 Answers

Have you tried to run:

spring stop

rails generate hangs may because spring is already running.

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

like image 150
lingceng Avatar answered Nov 10 '22 12:11

lingceng


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!

like image 44
ewakened Avatar answered Nov 10 '22 11:11

ewakened