How to start rails console on my ubuntu server
I am debugging an issue with a rails app on my ubuntu server and I am trying to start the rails console to run the command, but this is what happens when I try to start the console:
myuser@rails-server1:/var/www/myapp/current$ rails c
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install <selected package>
Rails is definitely installed because my application is running and the gem is installed in this directory:
/var/www/myapp/shared/bundle/ruby/2.0.0/gems
So how can I start the rails console?
source to share
First, let's find out how you installed Ruby: apt-get , rvm, or rbenv :
open a shell and type this
# type rbenv | head -1
# type rvm | head -1
each command will return "xxx is a function or " - bash: type: xxx: not found " (where" xxx "is" rbenv "or" rvm ").
"xxx is a function" means what you set using the xxx method .
If both commands return "xxx: not found" then you installed using apt-get and you will need to reinstall using rbenv or rvm.
Now that you know which manager you were using, try to fix the problem.
If you installed using RVM try this:
# \curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
# echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
If you installed via RBENV try this:
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
Close terminal, reopen and try again "rails c"
PS: If none of this works, try installing another manager (if you are using RVM, try installing via RBENV and vice versa).
source to share
looks like is rails
not in your path, so you will need to provide a path to it (and generally speaking, is .
not in your path in any * nix safe configured field)
try this in /var/www/myapp/current
RAILS_ENV=production ./bin/rails console
This will give you a console using the version of rails that was installed in your kit, and you are in the correct environment.
source to share