14

I'm new to ruby and rails and i installed rails in to the ubuntu. but when i go to the start server by typing "rails s" it doesn't start and comes following message . but i can create a new project by command rails new new_project. please rails specialists help-out me.

root@ubuntu:~# rails s Usage: rails new APP_PATH [options] Options: -j, [--javascript=JAVASCRIPT] 
# Preconfigure for selected JavaScript library # Default: jquery -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 -J, [--skip-javascript] # Skip JavaScript files [--edge] 
# Setup the application with Gemfile pointing to Rails repository -G, [--skip-git] 
# Skip Git ignores and keeps -d, [--database=DATABASE] 
# Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) 
# Default: sqlite3 -b, [--builder=BUILDER] 
# Path to a application builder (can be a filesystem path or URL) -r, [--ruby=PATH] 
# Path to the Ruby binary of your choice 
# Default: /usr/bin/ruby1.8 [--old-style-hash] 
# Force using old style hash (:foo => 'bar') on Ruby >= 1.9 [--skip-gemfile] 
# Don't create a Gemfile -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: -q, [--quiet] 
# Supress status output -f, [--force] 
# Overwrite files that already exist -s, [--skip] 
# Skip files that already exist -p, [--pretend] 
# Run but do not make any changes 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
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
Gihan Dilusha
  • 891
  • 4
  • 14
  • 22

6 Answers6

34

A better method is to update your bin using following command

bundle exec rake rails:update:bin
Pradeep Kumar Mishra
  • 10,839
  • 4
  • 25
  • 26
  • 1
    Thank you, that really helped. Could not find the difference between the not-working rails command and the working one in an older Rails app. Can you explain this? Why was this directory missing? – Sebastian Wramba May 26 '14 at 14:00
  • Yep, I'm also puzzled why the `rails new` command did not in the first place simply create the files created by that command. `rails new` did create `bin\bundle` and `bin\setup`, but not `bin\rails` and `bin\rake`. – Teemu Leisti Aug 27 '15 at 00:00
11
  1. You need to create a new Rails app (unless you already have one)

    rails new my_app
    
  2. Go to your app directory

    cd my_app
    
  3. Start the server in that directory

    rails s
    
Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
fl00r
  • 82,987
  • 33
  • 217
  • 237
5

Once you have created the project and cd'd into it:

Use script/server if you are on rails version 2.x

Use script/rails server if you are on rails version 3.x

Use bin/rails server if you are on rails version 4.x

Unixmonkey
  • 18,485
  • 7
  • 55
  • 78
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
1

Before starting the rails server, you have to cd into the directory of your application. That's because the server needs to know which application it's supposed to be serving.

1

I ran into this problem and was confused for a minute until I realized I accidentally deleted my bin folder.

How to fix it:

  1. Backup your app.
  2. cd back out of the root of the Rails app.
  3. Run rails new name_of_your_app -- make sure it's the same name as the directory that already exists.
  4. Rails will build the folder again, asking you if you want to overwrite files, hit n for "no" each time it asks.
  5. Rails will add the missing bin files, whereas if you hit n for everything else it will keep everything else.
  6. In my case I was using HAML with an application.html.haml file, and so Rails also generated an application.html.erb file for me in views/layouts which I didn't need and so deleted. Notice any other files that were generated and delete any you don't want.
  7. Run rails s to start the WEBrick server.
Allen
  • 2,717
  • 2
  • 30
  • 34
1

I am also new to Ruby on rails. I find the same issue when accidentally my PC shutdown. I fix it by following steps.

  1. Create a new application. Rails new demo --Database=postgresql

  2. Copy the Bin folder of new Demo app.

  3. Remove the Bin folder of old App(That showing error)

  4. Paste the New bin folder from Demo App to old App.

  5. Start the server Rails server

Note you can copy the bin folder from Github. https://github.com/hoovercj/depot