Rails rake db:create does not work - ruby-on-rails

I come from a computer science and programming background, and I am familiar with a *nix CLI.
I am new to ruby on rails, and I am doing an online bootcamp. One of my lessons has me creating a new rails application. It starts out with the following commands to create a new rails application and create the database:
$ rails new bloccit -T
$ cd bloccit
$ rake db:create
When I run the rake command, the process just hangs. I let it run for 30 minutes, and it just sat there. When I do a hard interrupt, I get the following stack trace:
^C/Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/run.rb:99:in `gets': Interrupt
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/run.rb:99:in `verify_server_version'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/run.rb:56:in `run'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/run.rb:37:in `warm_run'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/run.rb:26:in `call'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client/command.rb:7:in `call'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/client.rb:26:in `run'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/bin/spring:48:in `<top (required)>'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `load'
from /Users/mikekeathley/.rvm/gems/ruby-2.2.1/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/mikekeathley/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/mikekeathley/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/mikekeathley/code/bloccit/bin/spring:13:in `<top (required)>'
from bin/rake:3:in `load'
from bin/rake:3:in `<main>'
I understand the stack trace: on line 99 in the run.rb file, the method gets is getting stuck. I just don't know anything about spring.
I am running Ruby 2.2.1p85, Rails 4.2.1, and sqlite3 1.3.10.

Stop spring by using command
bin/spring stop
and then run rake command again. It would fix this issue.

Related

Execute tests in RubyMine causes "uninitialized constant Spring::Client::Run::UNIXSocket" on Windows 7

In RubyMine, I try to run tests in debug (equivalent to rails test, but with debug mode in RubyMine). I get this log in RubyMine console:
Testing started at 08:44 ...
C:\Ruby23-x64\bin\ruby.exe C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby-debug-ide-0.7.0.beta4/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 55232 --host 0.0.0.0 --dispatcher-port 55233 -- C:/Users/[ANONYMOUS]/bin/rails test
Fast Debugger (ruby-debug-ide 0.7.0.beta4, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:55232
Uncaught exception: uninitialized constant Spring::Client::Run::UNIXSocket
Did you mean? Socket
IPSocket
UDPSocket
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/run.rb:26:in `connect'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/run.rb:31:in `call'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:24:in `call'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
C:/Users/[ANONYMOUS]/bin/spring:15:in `<top (required)>'
C:/Users/[ANONYMOUS]/bin/rails:3:in `load'
C:/Users/[ANONYMOUS]/bin/rails:3:in `<top (required)>'
Process finished with exit code 0
It seems like RubyMine tries to run against some UNIX configuration, but I couldn't find anything related to this in my files.
I run RubyMine with Ruby 2.3.3, on Windows 7, RubyMine 2018.1.4.
When I run tests without the debug mode, everything is fine.
How could I resolve this problem? Thanks.
You need to uninstall spring as it's not supported on Windows.
From thier README:
Spring makes extensive use of Process.fork, so won't be able to provide a speed up on platforms which don't support forking (Windows, JRuby).
To uninstall:
'Unspring' your bin/ executables:
spring binstub --remove --all
Remove spring from your Gemfile
Recreate your gemlock file by running:
bundle install

How do I run specs for the activeadmin gem

I am trying to run the specs for a local clone of the activeadmin gems current master.
I am using ruby 2.2.2 and have bundled successfully.
When I try to run one of the specs like so:
bundle exec rspec spec/unit/filters/humanized_spec.rb
I am getting the following error:
The git source https://github.com/jruby/activerecord-jdbc-adapter is not yet checked out. Please run `bundle install` before trying to start your application
Coverage report generated for RSpec to /Users/aljoscha/gem/activeadmin/coverage. 0.0 / 0.0 LOC (100.0%) covered.
/Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `require': cannot load such file -- active_record (LoadError)
from /Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `<top (required)>'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `require'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `<main>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
which I cannot make sense of.
Especially since activerecord-jdbc-adapter is not even in the Gemfile.
What am I missing?
Try prepending your command with bundle exec:
bundle exec rspec spec/unit/filters/humanized_spec.rb
It looks like you have a local version discrepancy causing issues.
If not, did you follow all of the steps listed on their contributing readme?
If you are still stuck, you may be experiencing an issue with bundler itself. First, try updating bundler then reinstalling gems and attempt to run rspec. If that doesn't work you may need to delete the bundle cache folder and start over.
I'm going to re-answer to emphasize how to test a gem using appraisal as mentioned in CONTIBUTING:
bundle exec appraisal install
bundle exec appraisal rails_50 rspec spec/unit/filters/humanized_spec.rb
Thank you for your interest in Active Admin.

Rake aborted: Don't know how to migrate after rails install

I'm trying to go from a newly installed version of rails. To creating a project and migrating the database based off of the model that I scaffolded using rails. And I'm running into a Don't know how to build task 'db::migrate' error.
Commands I ran..
Removing all gems:
for i in 'gem list --no-versions'; do gem uninstall -aIx $i; done
Installing rails and creating new project
sudo gem install rails
rails new test-api
rails generate controller user index
rails generate model user name:string
So that is my setup..
Then I did the method to migrate my database:
rake db::migrate
And here was my output:
rake db::migrate
rake aborted!
Don't know how to build task 'db::migrate'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/command_wrapper.rb:40:in `call'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
-e:1:in `<main>'
(See full trace by running task with --trace)
I found a solution. Had I just refreshed my page on my server I would have found this:
Which gave me the answer to just run this command:
bin/rake db:migrate RAILS_ENV=development

Webrick Rails server won't start?

I'm using Rails 4.0.0, and successfully installed the mysql2 gem yesterday (mysql-0.3.15) using mysql-connector-c-6.1.3.winx64. I created a new Rails project called "simple_cms" using rails new simple_cms -d mysql which worked, and then ran bundle install which was also fine.
When I try to run rails server I get the following errors:
C:\Users\Hans>cd sites
C:\Users\Hans\Sites>cd simple_cms
C:\Users\Hans\Sites\simple_cms>rails server
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in
`requir e': 126: The specified module could not be found. -
C:/Ruby200-x64/lib/ruby/ge
ms/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.15/mysql2/mysql2.so
(LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb :8:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler.rb:132:in `require'
from C:/Users/Hans/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
C:\Users\Hans\Sites\simple_cms>
What can I do about this? By the way, the module it cannot find is in fact there.
28-Mar-2014 After all the problems I had installing and re-installing, I still could not get rails server to run. As I mainly want this installation to learn Ruby on Rails, I have instead installed the Bitnami Ruby stack, which installs everything automatically. This seems to work fine, and I've got Ruby, MySQL and the Apache Web Server working.
I had similar problems configuring the Lynda course on learning Ruby on Rails. I found an additional step that seemed to work for me. Since the error was complaining about the lack of a database in mysql, I created the missing database and that fixed the problem.
Log into mysql as root and prompt for password:
mysql -u root -p
Then:
SHOW DATABASES;
CREATE DATABASE simple_cms_development;
exit;

sunspot_solr error on heroku?

I'm using 'sunspot_rails', '~> 2.0.0.pre.120415' for Solr search in my rails app and deploy it on heroku (two separate application).
It's working fine on one application but throw error on other.
I have checked the heroku environment and found that -
one app is on cedar stack and ruby version is 1.9.2p290. (Working fine)
other one is on bamboo stack and ruby version is 1.9.2p180 (throw error)
So, Is this the ruby version problem or heroku stack problem ?
Ruby version on development environment is 1.9.2p290.
Error
$ heroku run rake sunspot:reindex
Running rake sunspot:reindex attached to terminal... up, run.8567
rake aborted!
uninitialized constant Sunspot::Adapters::Registry::Forwardable
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:310:in `<class:Registry>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:309:in `<module:Adapters>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:34:in `<module:Sunspot>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:18:in `block in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot/rails.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot_rails.rb:6:in `<top (required)>'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
To be even more clear, at the top of adapters.rb (sunspot/lib/sunspot/adapters.rb), add the following line:
require 'forwardable'
module Sunspot
#
# Sunspot works by saving references to the primary key (or natural ID) of
I have found the solution.
Actually it's a environment problem on heroku.On local system the ruby version is ruby 1.9.2p290 and on heroku is ruby 1.9.2p180. Ruby 1.9.2p180 doesn't include 'Forwardable' module. So I just need to include 'Forwardable' module in my application.

Resources