【Ruby On Rails】 「rails generate」が動かない


「rails generate」を実行するとハングアップしてしまい、「Ctrl+C」をでcancelすると下記のようにエラーがでた。
# rails g scaffold user name:string age:integer

^C/usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `gets': Interrupt
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
        from /usr/local/rvm/gems/ruby-2.1.1@circle/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
        from /root/develop/circle/bin/spring:16:in `require'
        from /root/develop/circle/bin/spring:16:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

springというライブラリが悪さをしているみたい。
同じ症状の人がいました。

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

この人の言うとおりにspringを再起動

# spring stop
Spring stopped.

# bin/spring

Version: 1.1.3

Usage: spring COMMAND [ARGS]

Commands for spring itself:

  binstub         Generate spring based binstubs. Use --all to generate a binstub for all known commands.
  help            Print available commands.
  status          Show current status.
  stop            Stop all spring processes for this project.

Commands for your application:

  rails           Run a rails command. The following sub commands will use spring: console, runner, generate, destroy.
  rake            Runs the rake command

そして再度「rails generate」を実行したら動いた。

# rails g scaffold user name:string age:integer

      invoke  active_record
      create    db/migrate/20140619065907_create_users.rb
      create    app/models/user.rb
      invoke  resource_route
       route    resources :users
      invoke  scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    helper
      create      app/helpers/users_helper.rb
      invoke    jbuilder
      create      app/views/users/index.json.jbuilder
      create      app/views/users/show.json.jbuilder
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/users.js.coffee
      invoke    scss
      create      app/assets/stylesheets/users.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

こんなことで時間をくってしまった!!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です