typing 'rails console' doesn't start?
Are you in the root path of your app when you type $ rails console
?
Tip: $ rails c
is a shortcut for $ rails console
rails console doesn't start
I may be answering a bit late for this, but for the sake of the others who are looking for the answer... it's here
Basically, enter this command
spring stop
The issue , as far as I understand, is with the spring
gem, specifically, it checks the server for versions, which doesn't tally up.
For my case, the problem started when when I add some new gems into the gemfile.
So once you stop spring and type in any other rails command, spring restart, and every thing should work again, at least until the same problem occurs, or the dev patched the issue.
Rails console doesn't start?
Have you created a Rails app? Looks like you're running rails console
in a directory that has no Rails app created yet.
You should create a new app using rails new [app_name]
, then run rails console
. Or, make sure that you're in the root directory of your existing Rails app.
Rails Console Not Loading
It could be that there are multiple versions of readline installed.
Try the following:
brew link readline --force
Rails: system process won't start in rails server, but will in rails console
You're creating an orphaned process in the way that you use system()
to start the ngrok process in the background:
system("ngrok start --all -log=stdout > #{ENV['APP_ROOT']}/log/ngrok.log &")
Note the &
at the end of the commandline.
I'd need more details about your runtime environment to tell precisely which system policy kills the orphaned ngrok process right after starting it (which OS? if Linux, is it based on systemd? how do you start rails server, from a terminal or as a system service?).
But what's happening is this:
system()
starts an instance of/bin/sh
to interpret the commandline/bin/sh
starts the ngrok process in the background and terminates- ngrok is now "orphaned", meaning that its parent process
/bin/sh
is terminated, so that the ngrok process can't bewait(2)
ed for - depending on the environment, the terminating
/bin/sh
may kill ngrok with a SIGHUP signal - or the OS re-parents ngrok, normally to the init-process (but this depends)
When you use the rails console or byebug, in both cases you're entering an interactive environment, which prepares "process groups", "session ids" and "controlling terminals" in a way suitable for interactive execution. These properties are inherited by child processes, like ngrok. This influences system policies regarding the handling of the orphaned background process.
When ngrok is started from rails server, these properties will be different (depending on the way rails server is started).
Here's a nice article about some of the OS mechanisms that might be involved: https://www.jstorimer.com/blogs/workingwithcode/7766093-daemon-processes-in-ruby
You would probably have better success by using Ruby's Process.spawn
to start the background process, in combination with Process.detach
in your case. This would avoid orphaning the ngrok process.
Command line won't let me type, in the midst of a Rails Console session
Something you've typed, or something output from your query in console, has disabled or redirected the "echo" setting in your shell - so, you're still able to type commands, but you just can't see them. If the Active Record query returned binary data, it's quite likely that some bytes of the binary data happened to be an escape code that changed your echo setting. It's also important to realize that if your echo setting changed, it's quite possible that other settings have changed as well.
If you're at your shell prompt, you would just type the unix command reset
to restore normal settings. However, if you're still in your Rails console, you'll need to type:
system 'reset'
to run that command from Ruby.
Related Topics
Best Way to Debug Third-Party Gems in Ruby
What to Use Instead of 'Render :Text' (And 'Render Nothing: True') in Rails 5.1 and Later
How to Find the Namespace/Module Name Programmatically in Ruby on Rails
How to Alter the Timezone of a Datetime in Ruby
How to Debug in Rubymine 4.5 Using Ruby 1.9.3
Why Does Code Need to Be Reloaded in Rails 3
Changing Table Name at Query Run Time in a Rails Application
How to Access the Rack Environment from Within Rails
Rails: How to Use Dependent: :Destroy in Rails
How to Url Encode a String in Ruby
How to Configure Capistrano to Use My Rvm Version of Ruby
Where to Put Ruby Helper Methods for Rails Controllers
Guard with Rspec on Rails 4 Giving a Lot of Warnings
How to Save an Object to a File
How to Capture Values in Command Line and Add to Recipe