質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

586閲覧

rails g controllerが動きません

joruju1988

総合スコア10

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/04/28 22:20

編集2020/04/29 01:38

コマンドで

$ rails g controller linebot

と打った際、以下のようなエラー文が出てしまいます。

/Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle Reason: image not found - /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle (LoadError) from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291:in `block in require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:257:in `load_dependency' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<top (required)>' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require' from /Users/shopuroguramingu/anket2/config/application.rb:7:in `<top (required)>' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:92:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:92:in `preload' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `run' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' from /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' from -e:1:in `<main>'

試したこと

bundle installをしてからrails g controller linebotを打った。
spring stopをしてからrails g controller linebotを打った。
gem updateをしてからrails g controller linebotを打った。

いずれも、うまくrails g controller linebotが動きません。

どのようにエラー文を解釈すれば良いかもよくわかりません。
回答よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

rails g controller コントローラー名

ですね。
コントラーラ名_controller.rb が作られます

投稿2020/04/29 00:01

winterboum

総合スコア23382

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

joruju1988

2020/04/29 01:41

すみません、質問の記載ミスでした!修正いたしました!よろしくお願いします
winterboum

2020/04/29 02:22

require': dlopen(/Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle Reason: image not found - /Users/shopuroguramingu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle とありますから、mysql2のbundleの確認をしてみてください
guest

0

自己解決

原因は、以前にmySQLをインストールした時と現在のファイルのバージョンが違ったので、今回インストールしたmySQLが以前のバージョンのファイル達を参照した時に齟齬が出てエラーが発生するというものでした。

$ sudo rm -rf /usr/local/mysql $ sudo rm -rf /Library/StartupItems/MYSQL $ sudo rm -rf /Library/PreferencePanes/MySQL.prefPane $ sudo rm -rf /Library/Receipts/mysql-.pkg $ sudo rm -rf /usr/local/Cellar/mysql* $ sudo rm -rf /usr/local/bin/mysql* $ sudo rm -rf /usr/local/var/mysql* $ sudo rm -rf /usr/local/etc/my.cnf $ sudo rm -rf /usr/local/share/mysql* $ sudo rm -rf /usr/local/opt/mysql*

で、関連ファイルを削除して、さらに

$ bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"

とすることで、bundlerを使ってmysql2を入れる際、以下のような場所にあるライブラリを使ってくれるようになる。

$ brew --prefix openssl => /usr/local/opt/openssl@1.1

今回もそうだったのですが、
MacOSをアップグレードした後、mysql2のインストールで問題が発生することがあるようです。

参考記事
https://qiita.com/usagrammer/items/7a6b9b9e67f301b5e58a

https://github.com/brianmario/mysql2/issues/1005

投稿2020/05/01 09:39

joruju1988

総合スコア10

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問