0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[小ネタ] railsでサーバー接続時にエラーが発生する

Last updated at Posted at 2019-03-05

完全に小ネタです!
ただ、経験したことある方もいるかと思います。
結論から言うとパスには気を付けましょうということですね。はい....

今回起こった事象####

cloud9でGithubからクローンしたリポジトリで開発を行おうとしていました。
とりあえずクローンしてサーバーに接続してみようと思うと下記エラーが発生しました

aws-test:~/clone_article $ rails server -b 0.0.0.0
Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]            # Skip namespace (affects only isolated applications)
  -r, [--ruby=PATH]                                        # Path to the Ruby binary of your choice
                                                           # Default: /usr/local/rvm/rubies/ruby-2.4.1/bin/ruby
  -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/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                                           # Default: sqlite3
      [--skip-yarn], [--no-skip-yarn]                      # Don't use Yarn for managing JavaScript dependencies
      [--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
  -O, [--skip-active-record], [--no-skip-active-record]    # Skip Active Record files
      [--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.....

rails new APP_PATH [options]を初めて見たときは何だこれと思い、少し焦りました。
2、3回試し、同じエラーが発生したので、やり方が悪いのかと思い、少し調べました。

原因####

今いるディレクトリーが Rails アプリのルートディレクトリーでないことが原因でした。
clone_article配下にrails-articleRecord/ があり、そこがRails アプリのルートディレクトリーでした。
ディレクトリを移動させるとうまくいきました。

aws-test:~/clone_article $ cd rails-record/
aws-test:~/clone_article/rails-record (master) $ rails server -b 0.0.0.0
=> Booting Puma
=> Rails 5.2.2 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.4.1-p111), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:8080
Use Ctrl-C to stop

パス間違いはRailsに限らず、起こりえることなので、よく確認してみると、エラーを確認する時間を短縮できるかもしれません。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?