0
0

More than 1 year has passed since last update.

Rails Cloud9からローカル環境へ(備忘録)2

Posted at

前回の続き

時間がだいぶ経ちましたが前回の記事の続きについて記載していきます。

環境

・macOS BigSur 11.6
・Ruby 2.5.3
・Rails 5.2.6
・Homebrew 3.2.16


MYSQLのインストール

$ brew install mysql

PASSを通す

$ echo 'export PATH="/usr/local/opt/mysql/bin:$PATH"' >> ~/.zshrc

設定を反映

$ source ~/.zshrc

MYSQLの起動、接続確認

$ brew services start mysql
%$mysql -uroot

mimemagicのライセンス更新

$ bundle install

エラー発生

An error occurred while installing mimemagic (0.3.10), and Bundler cannot continue.
Make sure that `gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/'` succeeds before bundling.

新しいライセンスのmimemagicをインストール

$ brew install shared-mime-info

再度

$ bundle install

成功

Bundle complete! 18 Gemfile dependencies, 73 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

MY SQLの設定変更

サーバー起動

$ rails s

MYSQLあたりでエラー発生

image.png

エラーが発生したファイルがあるか確認

どうやらrailsのconfig/database.ymlの設定がおかしいようなので、設定を変更

username、password、socketの修正

 username: root
 password: 
 socket: /tmp/mysql.sock

アプリ起動

$ rails s

エラー発生。データベースを作成していなかった。。。

$ rails db:create
$ rails db:migrate
$ rails s

localhost:3000に接続すると、無事にアプリを起動できました!

いろいろな方の知見をお借りしてなんとかできました。
間違い等あればご指導、ご鞭撻のほどよろしくお願いします。
まだまだ勉強が必要ですね。

参考

https://qiita.com/tkmd35/items/c26d1dffca4be0a4f017
https://qiita.com/koki0527/items/5eb8d8c1ac56dcd05466

0
0
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
0