I\'m new to rails and decided this morning to dump my whole database design/model and start over. And being a noob, I\'m sure did it incorrectly.
I removed all the files
TL;DR: Restarting computer worked for me.
I had the same problem, and although the chosen answer worked, I wasn't comfortable deleting a bunch of stuff I admittedly don't fully understand. My git status on the bin
dir looked like this, after deleting the bin dir and running rails app:update:bin
deleted: bin/bundle
modified: bin/rails
modified: bin/rake
modified: bin/setup
deleted: bin/spring
deleted: bin/webpack
deleted: bin/webpack-dev-server
deleted: bin/yarn
I felt like something might come back to bite me later, so after reading the article referenced in the accepted answer (http://www.dixis.com/?p=754) I decided to just restart my computer, as that would fix any networking issues. It worked like a charm.
Found this over at http://www.dixis.com/?p=754
For one of my projects I am using rails 4.1 (bleeding edge! yeah :) ) and suddenly noticed, that after opening my laptop in the morning my normal rails commands, like
$> rails c
$> rails g migration Bla name description some_more_fields
just … were hanging and nothing happened??? Like they were waiting for further input. Upon closer investigation, I assumed that the connection to the spring process was lost/corrupt (I move between networks a lot? maybe that could explain it).
For those unaware, as I was, spring is a Rails application preloader. It speeds up development by keeping your application running in the background so you don’t need to boot it every time you run a test, rake task or migration. Of course when that connection is lost, or corrupt, it hangs.
A simple
$> spring stop
stops the spring server, after which any rails command will restart it automatically. Fixed :)
I had the same problem when trying use rails g controller
and it would just hang. I used the same steps @mtrolle suggested:
bundle config --delete bin
rails app:update:bin
git add bin
So when I ran:
rails g controller Project index
it created the controller, helpers, and index view and GET 'project/index'
route as expected.
If your rails generate
commands hangs, it is most likely that the generated binstubs of rails are the issue. As you mentioned, you renamed the project.
My educated guess is that some paths in the binstubs were still set to the old project directory but did not exist any longer.
There is a great article on how binstubs work here: https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs
rails 4
To reset the binstubs, just delete your bin/
directory in rails and run:
# generates binstubs for ALL gems in the bundle
bundle install --binstubs
# ...OR, generate binstubs for a SINGLE gem (recommended)
bundle binstubs rake
rails 5/rails 6
To reset the binstubs, just delete your bin/
directory in rails and run:
rake app:update:bin
Why do we need to use the 'rake' command for rails 5 and higher, and not the 'rails' command itself?
Since rails 5 some 'rake' commands are encapsulated within the 'rails' command. However when one deletes 'bin/' directory one is also removeing the 'rails' command itself, thus one needs to go back to 'rake' for the reset since 'rails' is not available any longer but 'rake' still is.
In Rails 5 the binstups are created using the rails
command.
I just deleted the bin folder myself and then ran rails app:update:bin
which fixed my problems.
In Rails 5, your app's bin/ directory contains executables that are versioned like any other source code, rather than stubs that are generated on demand.
Here's how to upgrade:
bundle config --delete bin # Turn off Bundler's stub generator rails app:update:bin # Use the new Rails 5 executables git add bin # Add bin/ to source control
I just had to kill spring
.
$ rails generate yaddi-yaddi-yadda
hang...
hang...
hang..
^C
$ ps -u {user} | grep rails
123 123456 spring app ...
Find the pid, then kill spring
.
$ rails generate yaddi-yaddi-yadda
# success.