rails server just prints command usage [duplicate] - ruby-on-rails

This question already has answers here:
Rails server does not start by command "Rails s"
(6 answers)
Closed 9 years ago.
$ rails server
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/bikram/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install
-G, [--skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record] # Skip Active Record files
-S, [--skip-sprockets] # Skip Sprockets files
-d, [--database=DATABASE] # Preconfigure for selected database (options:
mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-T, [--skip-test-unit] # Skip Test::Unit files
[--old-style-hash] # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Suppress status output
-s, [--skip] # Skip files that already exist
Rails options:
-h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
It generated like this but not rails local server. Other versions are:
Rails 3.2.14
ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
gem 2.1.9
rvm 1.23.9 (stable)
my gem file is:
source 'https://rubygems.org'
gem 'rails', '3.2.14'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :test do
gem 'capybara', '1.1.2'
end
group :production do
gem 'pg', '0.12.2'
end

This is the default message generated when you try to launch the Rails server in a folder without a Rails application.
You need to run rails new <appname> where appname is the folder you're in prior to launching the server.
If it is a Rails application, then you're likely missing some key files that the server command uses to determine if it is a Rails application.

I guess you are running the command rails server while not in (the root directory) of a Rails application.
Change into your Rails project directory and try again.

Related

Trouble installing Ruby on Rails in Windows - no localhost

I'm new to Ruby / Ruby on Rails, and coding in general. I've gone through the Ruby course on Code Academy, and now I'm about to do Ruby on Rails, but was hoping to actually make something as I go through the course, to help with my understanding of it.
I've tried using Windows Command Prompt and Git Bash to make a new rails app. It seems to run fine when I type rails new MySite. It creates a folder in the right place. This also seems to run bundle install on it's own, and if I type bundle install, it says Could not locate Gemfile. But when I type rails server, it doesn't give me a localhost at all. It just says:
Usage:
rails new APP_PATH [options]
Options:
[--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated engines)
[--skip-collision-check], [--no-skip-collision-check] # Skip collision check
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/Ruby27-x64/bin/ruby.exe
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files
[--skip-action-mailbox], [--no-skip-action-mailbox] # Skip Action Mailbox gem
[--skip-action-text], [--no-skip-action-text] # Skip Action Text gem
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
[--skip-active-job], [--no-skip-active-job] # Skip Active Job
[--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage files
-P, [--skip-puma], [--no-skip-puma] # Skip Puma related files
-C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
[--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
[--skip-jbuilder], [--no-skip-jbuilder] # Skip jbuilder gem
-T, [--skip-test], [--no-skip-test] # Skip test files
[--skip-system-test], [--no-skip-system-test] # Skip system test files
[--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem
[--dev], [--no-dev] # Set up the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Set up the application with Gemfile pointing to Rails repository
[--master], [--no-master] # Set up the application with Gemfile pointing to Rails repository main branch
[--rc=RC] # Path to file containing extra configuration options for rails command
[--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file
[--api], [--no-api] # Preconfigure smaller stack for API only apps
[--minimal], [--no-minimal] # Preconfigure a minimal rails app
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
--webpacker, [--webpack=WEBPACK] # Preconfigure Webpack with a particular framework (options: react, vue, angular, elm, stimulus)
[--skip-webpack-install], [--no-skip-webpack-install] # Don't run Webpack install
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
Rails options:
-h, [--help], [--no-help] # Show this help message and quit
-v, [--version], [--no-version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory,
or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
I've also tried installing Ubuntu (20.04 LTS), as I've read that it can help with rails issues, but I can't get that to work either - I can't even set up a username and password, as it says
The specified network name is no longer available
I have:
Windows 10, Version 2004 (OS Build 19041.1052)
Rails 6.1.4
Ruby 2.7.3p183
Yarn 1.22.10
Node v14.17.2
I'm sorry if I've given too much / not the right info - not sure what would be helpful. I spent most of today and yesterday googling this and trying to figure it out, but I've hit a wall. Any help would be really appreciated

Why doesn't "rails s" work from the app directory?

I'm in my app folder, but the command rails s is not working. I read through quite a few posts on Stack Overflow, and most of them seem to be from users who are not in their app directory.
In addition, I built a few other apps. I checked those, and the Rails server works for all of those apps. This is the only one where I can't get it to launch.
Output of which rails:
/Users/jmcrist/.rvm/gems/ruby-2.0.0-p247/bin/rails
Output of rails s:
MacBook-Pro:first_app jmcrist$ rails s
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/jmcrist/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install
-G, [--skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record] # Skip Active Record files
-S, [--skip-sprockets] # Skip Sprockets files
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-T, [--skip-test-unit] # Skip Test::Unit files
[--old-style-hash] # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Suppress status output
-s, [--skip] # Skip files that already exist
Rails options:
-h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
I'm working through Hartl's Rails Tutorial, and he makes quite a few modifications to the gemfile. I am wondering if this might be the cause?
source 'https://rubygems.org'
gem 'rails', '3.2.13'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :production do
gem 'pg', '0.12.2'
end
It seems to think you are not in a rails directory (your output is saying the only valid way to use rails is with rails new).
Depending on your version, Rails identifies this differently. On 3.2, it checks for a file at script/rails. Now that 4.0 has been released, it looks for either script/rails or bin/rails (https://github.com/rails/rails/blob/207fa5c11ddf1cfd696f0eeb07d6466aae9d451e/railties/lib/rails/app_rails_loader.rb#L6)
Presumably you can get around this by creating the file rails in your script directory (if you do not have a script directory, create one in the root of your app):
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
Of course, it's worth wondering why you don't have this file in the first place. Might be worth making sure your rails is the version you want to be using first (rails -v if the version is newer, this post will show you how to create the new app using the older version).
Possible reasons:
you are not in a directory that contains a full rails app
your bin directory might me empty, try to run rake rails:update:bin (for Rails 4) or rails app:update:bin (Rails 5)
All the above answers didn't help me. What solved my problem for Rails 4 was to run command in the root directory of my application:
rake rails:update:bin
After that running rails s was running as expected.
If you use rvm or rbenv for instance to keep multiple ruby versions, maybe your default rails version for that specific ruby version is different than the project you are trying to run and therefore it's not being able to detect your application.
To make sure you are using the right rails version you can compare both results. This is what I've got:
$ rails -v
Rails 3.1.0
to
$ bundle exec rails -v
Rails 5.0.0.1
In this case, you can keep the default rails version and then use:
$ bundle exec rails server
Or install the specific rails gem to that very ruby version with:
$ gem install rails -v 5.0.0.1
$ rails -v
Rails 5.0.0.1
And then get it working with the less verbose command:
$ rails s
I hope this becomes helpful to other folks in the same situation!
You likely have not bundled your gems yet:
# from command line
bundle install
I had this problem, took me a few minutes to realize I'd forgotten to change active Ruby version with chruby. Different Ruby implied a different Rails version, which looked for the relevant file in another folder.
First check with your location path and then
bundle install
If still does not work, enter
/bin/bash --login
bundle install
This works for me.!!!(NOTE: run this commands into rails app)
rake db:migrate RAILS_ENV=development;
Run this command to generate /bin
rake rails:update:bin
OR
rake app:update:bin
=============================================
Then you will get this kind of screen(In that Go with Y)
bin/rails? (enter "h" for help) [Ynaqdhm] Y
Then you can start the server using
rails s

Rails server is started but localhost:3000 shows error

I have just installed Ruby on Rails package that found in http://rubyinstaller.org/ (This is my first attempt to set up the ruby on rails workstation in my xp sp3 system.). The installation process went perfectly without any errors. I started the server using it's console. Server is started but http://localhost:3000 shows an error page (page not found).
I have following display in the console.Am i missing anything?
#Rails Environment Configuration.
---
git:
user.name: XYZ
user.email: xyzuser
version: git version 1.8.1.msysgit.1
ruby:
bin: C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe
version: ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
rails:
bin: C:/RailsInstaller/Ruby1.9.3/bin/rails.bat
version: Rails 3.2.13
ssh:
public_key_location: C:\Documents and Settings\xyz/.ssh/id_rsa.pub
public_key_contents: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArYKMRvMHxKJ2R//5viqQp
D4IQhVcKZhhbfvZGzDOXF1M//pewAQDK2x9y8T8irvatgmDMCYB5L2uZiyXwG3gPm6Bfw44mCHhNP8xN
bT2OSDnvIoZcFVfmQExZmwWcSNqm0NionObUV+IFKvfjg9bOPl4GBUqSXSTlUmAn/wQq0c/m+GoJwDlI
dV/h69dq4tHYwpCMFUZ9k4LqR4VICktV5Fi1VQA14u4Y9kOWAAyAfzeXnOzcpkbYxgjbCvAf20gM6lSL
9NvNsLuzI5yLxhI5wAmZbK+11zgNmx019tbv1uHvZRV2Z53aWpErtuvipAieQ977U4kYQPMyFf8g8BKd
Q== XYZ<xyzuser>
C:\Sites>
And the console output when the server is started is:
C:\Sites>rails s
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/RailsInstaller/Ruby1.9.3/bin/ruby
.exe
-b, [--builder=BUILDER] # Path to a application builder (can be a files
ystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a fil
esystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install
-G, [--skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record] # Skip Active Record files
-S, [--skip-sprockets] # Skip Sprockets files
-d, [--database=DATABASE] # Preconfigure for selected database (options:
mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3
/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing t
o your Rails checkout
[--edge] # Setup the application with Gemfile pointing t
o Rails repository
-T, [--skip-test-unit] # Skip Test::Unit files
[--old-style-hash] # Force using old style hash (:foo => 'bar') on
Ruby >= 1.9
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Suppress status output
-s, [--skip] # Skip files that already exist
Rails options:
-h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
C:\Sites>
Thank you everyone. Finally I got it worked. The problem was the Gemfile in my test_app folder. I commented on the line gem 'uglifier', '>= 1.0.3' and i got it worked. Hopefully it will work further as well and let me move on.
You have to cd in the directory of the created rails project, then rails s should work fine.
This means also, that the server has not started yet. Please read carefully the output of the console commands, most of the time they tell you what they do, or why they don't work as expected.
First of all you have to create a new rails project. I think that C:/Sites is not your rails project directory.
rails new test_app
It will create a rails project in your directory. than go to cd test_app. and try to start your server.
Hope it will work.
Server is not started. You need to navigate to your rails app folder, install needed gems and start the server:
cd <your app folder>
bundle install
rails s

Not able to run rails server

Any suggestions on why am I getting this? My ruby version is ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0] and rails version is Rails 3.1.1. I have done bundle install and gem update --system.
➜ expertiza git:(master) ✗ rails server
Usage:
rails new APP_PATH [options]
Options:
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/vsingh3/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-G, [--skip-git] # Skip Git ignores and keeps
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
[--old-style-hash] # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-O, [--skip-active-record] # Skip Active Record files
[--skip-bundle] # Don't run bundle install
-T, [--skip-test-unit] # Skip Test::Unit files
-S, [--skip-sprockets] # Skip Sprockets files
Runtime options:
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
Thanks!
I encountered this same problem a while back and I think it was due to an outdated gemfile. Make sure you have the same version of rails listed in your gemfile as is installed on your machine.
You should look in to using RVM if you don't currently. It will keep all of your environments for different applications separate (including ruby versions and gem lists/versions).

Rails new command not working

I run rails new search in my console, and I get all of this:
Usage:
rails new APP_PATH [options]
Options:
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
-G, [--skip-git] # Skip Git ignores and keeps
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-O, [--skip-active-record] # Skip Active Record files
Runtime options:
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
But it doesn't actually create the application. What's wrong here?
turns out I needed to install the rails gem again: gem install rails
Have you tried rails new ./search ?
I just tried it in windows, Ruby 1.9 w rails 3.0.9 and didn't have that problem.
If you're using RVM, try creating a new gemset and then install rails.
rvm gemset create better
rvm gemset use better
gem install rails -v x.x.x
rails new betterApplication

Resources