ドットインストールのRails入門#5は、ローカル環境でやる手順になっている。
https://dotinstall.com/lessons/basic_rails_v3/41805
しかし、ローカル環境構築に失敗したので、AWS cloud9で実行したところ、** rails g model **の段階でエラーが発生したので対処法を書きます。
環境
Windows10
AWS Cloud9
事象
ドットインストールの手順通りコマンドを打ったが数分待っても実行されず
teminallog
ec2-user:~/environment/myblog $ rails g model Post title:string body:text
Ctrl+Cでキャンセルするとこのようなログがでた
teminallog
ec2-user:~/environment/myblog $ rails g model Post title:string body:text
^CTraceback (most recent call last):
15: from bin/rails:3:in `<main>'
14: from bin/rails:3:in `load'
13: from /home/ec2-user/environment/myblog/bin/spring:15:in `<top (required)>'
12: from /home/ec2-user/environment/myblog/bin/spring:15:in `require'
11: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
10: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
9: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
8: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
7: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
6: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/rails.rb:24:in `call'
5: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
4: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/run.rb:35:in `call'
3: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/run.rb:42:in `warm_run'
2: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/run.rb:62:in `run'
1: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/run.rb:117:in `verify_server_version'
/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.1.1/lib/spring/client/run.rb:117:in `gets': Interrupt
いろいろ調べるとspringというGemfileの中に書いているパッケージが邪魔をすることがあるらしい。
そこでspring stopというコマンドでバックグランド処理しているspringを止めてみました
teminallog
ec2-user:~/environment/myblog $ spring stop
Spring stopped.
その後、** rails g model **を実行すると想定通りの結果が返ってきましたね!
teminallog
ec2-user:~/environment/myblog $ rails g model Post title:string body:text
Running via Spring preloader in process 12505
invoke active_record
create db/migrate/20201004132353_create_posts.rb
create app/models/post.rb
invoke test_unit
create test/models/post_test.rb
create test/fixtures/posts.yml