"Rails Generate" Not Working

Rails generate not working anymore

Please try this command bin/spring stop. Run generator command again.

Rails generate commands not working

I think Spring is misbehaving, and not re-requiring gems correctly.

Check spring's status with bin/spring status. If it's running, try stopping it with bin/spring stop. If it's not, check to see if there are any orphan Spring processes that might be screwing things up:

ps aux | grep spring.

I'm not entirely sure why Spring is acting like this, but killing it off fixed the issue for me. I was unable to replicate again to investigate further.

Problem with command rails generate model xxx

rbenv lets you switch between versions of ruby, but it doesn't install those versions for you. I'd suggest also installing ruby-build (which works with rbenv). Once you've done that, you should be able to run rbenv install 2.3.7 and fix your issue.

`rails generate minitest:install` not working

This is related to the new Webpacker included since Rails 5 and the suggested solution is to run yarn install, also another user stated that NODE_ENV was missing. You need to install yarn and fix the node issues first, then the issue will disappear.

See here, https://github.com/rails/webpacker/issues/1374

rails generate' commands hang when trying to create a model

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.



Related Topics



Leave a reply



Submit