はじめに
Railsチュートリアルで発生したエラーとか詰まったところをまとめていこうと思います。
備忘録として。
2週目の今回はbitbucketではなくgithubで進めていこうと思います。
rails newの時点でエラー発生
$rails _5.1.6_ new hello_app2
# エラー発生
can't find gem railties (= 5.1.6) with executable rails (Gem::GemNotFoundException)
対処方法が下記コマンド
$gem install rails -v 5.1.6
こちらで再度rails newコマンドすれば無事作成できました。
githubでのリポジトリ作成
いつもはgithubからローカルにクローンするやり方でやってたので今回はこちらで。
ローカルからプッシュするやり方で。
まずgithubでリポジトリ作成する。
名前はhello_app2にしました。
# ローカルリポジトリを作成するディレクトリに移動する
cd hello_app2
# ローカルリポジトリを作成する
$ git init
$ git add .
$ git commit -m "first commit
# リモートリポジトリのアクセス先を設定する
$ git remote add origin https://github.com/GitHubのユーザ名/GitHubのリポジトリ名(こちらではhello_app2).git
# pushする
$ git push -u origin master
git push heroku でエラー
エラー文
remote: !
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! Activating bundler (2.0.1) failed:
remote: ! Could not find 'bundler' (2.0.1) required by your /tmp/build_b85aaac02a3a812e844f20844711c628/Gemfile.lock.
remote: ! To update to the latest version installed on your system, run `bundle update --bundler`.
remote: ! To install the missing version, run `gem install bundler:2.0.1`
remote: ! Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote: !
remote: ! To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote: !
こちらのエラー分の中にあるように下記コマンド
$ gem install bundler -v 2.0.1
$ rm Gemfile.lock
$ bundle install
$ git add .
$ git commit -m 'hoge'
$ git push heroku master
こちらで解決し無事デプロイ完了しました。