Hey guys I have been working on a rails app, and the rails server was working. Then I added more code, and all the sudden the rails server is not working now. I keep getting this message:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/ethanfranson/.rvm/rubies/ruby-2.2.1/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-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], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--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
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.
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
My app is called bloccit, and in my terminal shell I am in my code/bloccit directory but still nothing. If anyone could help with any tips I would be very thankful!
rails s runs scripts located in your app's bin directory. Without it, you get the message shown above.
I asked for the contents of your app directory (using ls) and you responded:
Gemfile Rakefile config.ru log tmp Gemfile.lock
app db public vendor README.md config lib spec
As you can see, your bin directory is missing. It must be restored/replaced.
If you moved it or threw it in the trash, restore it.
If you deleted it, you can copy one from another/new Rails app. Create a folder somewhere outside your existing app, generate an empty Rails app (rails new throwaway), then go in and copy the bin folder to your existing app.
Make sure that you are in your root application directory. That error you posted is commonly seen if you are not in root application directory.
You can use pwd command to show where is your current directory. You said that your app name is bloccit and you should be in that root directory and fire rails s.
It's likely that it's suggesting you to create a new rails app because it's unable to identify your Rails app.
Since you're using Rails version 4.x, it looks for bin/rails to identify a Rails app. If you don't have bin directory at the root of your application, try to run rake rails:update:bin
Related
I'm trying to learn Ruby on Rails, in some other questions I read sometimes it's a problem with the Webrick server.
I think this time it has to do with the directory path. I am learning with an online course, so I think I need to stay with Webrick, if possible! My Rails version is 5.0.0.1
When I try to open a new server, using the command rails server this message appears:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/RailsInstaller/Ruby2.2.0/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/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-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
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record 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
-T, [--skip-test], [--no-skip-test] # Skip test files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--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
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.
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.
How can I fix it?
You need to change directory into the path of your application and then start the server.
If you haven't created an app yet, you need to do that first using rails new nameofapp
To change directory do this by running cd path/path/app and change the path to the correct path, and the app to the correct app name.
Then run rails server or rails s to start the server and go to http://localhost:3000 in your browser
When ever I type rails sin command line in WINDOWS 7 then it gives me following output:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/ror/Ruby22-x64/bin/ruby.exe
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-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], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--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
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.
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.
As you can see s command does not exist and rails g scaffold doesn't work as well, it gives same output.
More info:
I have installed rails and ruby and devkit correctly with no errors.
I typed
rails new testproject
and it worked fine, the testproject was created successfully.
I just can't type rails s.
After you run rails new appname, you need to cd appname before you can run server, console, etc. From your app root, you'll see a bin/rails, which is loaded when you're in your app directory and sets up all the app-specific commands via Rails::Commands. To avoid the opposite problem you're having, it also cleverly disallows creating a Rails app inside your Rails app.
I created a new app in desktop/maps.
I haven't linked it to github or anything and am just working locally.
I have previously used the rails s function and it worked perfectly however now that I want to pickup where i left off it now says:
Sachins-MacBook-Pro:maps sachinkaria$ rails s
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /usr/local/rvm/rubies/ruby-1.9.3-p392/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], [--no-skip-gemfile] # Don't create a Gemfile
[--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-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], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--old-style-hash], [--no-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], [--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.
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.
Please note i am in the correct directory and I've have previously run the started the server.
Which directory are you in? Running rails server will return the syntax banner you pasted unless the file config.ru is in the same directory.
If you're using Rails 4+, regenerate your app's bin/ directory executables:
rake rails:update:bin
These are versioned like any other source code, rather than stubs that are generated on demand with bundler. Using the regenerated executable should solve the problem.
I'm pretty new to rails, and trying to setup an extremely simple test site.
I've created the new rails app directory using the rails new command, but then cannot setup the server to view the page in a browser.
(Below is the message I receive when attempting rails server)
MacBook-Pro:documents AT$ rails server
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-V, [--skip-action-view], [--no-skip-action-view] # Skip Action View files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-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], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--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
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.
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.
make sure your bin folder isn't empty..you might need to run this if it is
rake rails:update:bin
Change your current directory to the project directory and execute the rails server command.
example:
$rails new demo_app
$cd demo_app
$rails s
rails server command will start the server if you are inside a rails project directory. When you execute rails new demo_app it creates a directory called demo_app, which contains your new rails project. In your case rails server did not work because you are not inside demo_app directory.
You are not in the rails app directory.
As you already have a project then go to its directory.
To change directory do:
cd path/to/project/rails_project_name
To setup the server to view the page in a browser, you need to be in rails project directory.
So just change directory to your project directory you just have created, using cd command as
cd path_of_rails_project
and now use rails server
for details, you can refer http://guides.rubyonrails.org/getting_started.html
You can not start the Rails server unless you're in your project directory.
Suppose if you're working on myapp project. You've to move to that project directory on your command line and then run the Rails server.
Example: Assuming you didn't create the Rails app yet:
$> rails new myapp
$> cd myapp
Now start the Rails server with either of these two commands:
$> rails server
or:
$> rails s
Assuming you have tried running this command in side the rails application directory, have you checked that your Rails application directory includes the /bin folder? If this is gone you will not be able to run common rails commands.
I ran into this problem and ended up creating a new rails application and copying the bin folder over to restore functionality.
When I run the command
rails g migration migration_name
I will get the "error" message:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/radek/.rvm/rubies/ruby-1.9.2-p290/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's first time when I got this message. In other projects this command works well, but here I am still getting this message...
What caused that? Am I missing something?
(yes, I am in the root of the respective project)
You are not running it inside a rails generated project directory. You are running it outside it.
EDIT: It could also be if the script folder is missing. Or the rails script is missing inside the script folder if you are executing it inside the project folder.
I've got the same, and i fixed by doing :
cd /root/path/to/your/project
bundle install
bundle update
VoilĂ :)
Try adding a folder called script to your rails root.
in this folder add a file called rails and add to it
APP_PATH = File.expand_path('../../config/application', FILE)
require File.expand_path('../../config/boot', FILE)
require 'rails/commands'
and execute again
rails g migration migration_name