“rails generate” not working

橙三吉。 提交于 2019-11-30 10:16:17

问题


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!


回答1:


Have you tried to run:

spring stop

rails generate hangs may because spring is already running.

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




回答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!



来源:https://stackoverflow.com/questions/23157426/rails-generate-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!