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

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

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

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby

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

Ruby on Rails

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

Q&A

2回答

2508閲覧

rails consoleが動かない

退会済みユーザー

退会済みユーザー

総合スコア0

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby

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

Ruby on Rails

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

0グッド

1クリップ

投稿2019/03/23 06:56

編集2019/03/23 07:05

前提・実現したいこと

ruby(rails)のローカル開発環境を整えようと思い、homebrewを使ってrbenvをインストールしました。
bundler, railsもインストールし、rails serverも動いたのですが、rails consoleを動かそうとするとエラーが起こってしまいconsoleが動きません。

以下にrails consoleを実行した際のエラー文を添付いたします。

発生している問題・エラーメッセージ

mac:helloapp gotchryu$ rails c /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError) from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<main>' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/connection_adapters/connection_specification.rb:191:in `spec' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:952:in `establish_connection' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/connection_handling.rb:60:in `establish_connection' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/railtie.rb:136:in `block (2 levels) in <class:Railtie>' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/base.rb:328:in `<module:ActiveRecord>' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/base.rb:27:in `<main>' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:356:in `active_record_configured?' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:273:in `disconnect_database' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:107:in `preload' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>' mac:helloapp gotchryu$ from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' from -e:1:in `<main>'

該当のソースコード(Gemfile)

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.2', '>= 5.2.2.1' # Use sqlite3 as the database for Active Record gem 'sqlite3', '~> 1.3.6' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

試したこと

~/.bash_profileに
eval "$(rbenv init -)"
を追記しました。(rbenv initした際に追記するようにと指示があったので)

gem 'sqlite3'

gem 'sqlite3', '~> 1.3.6'
に変更しました。

補足情報(FW/ツールのバージョンなど)

macOS High Sierra
Version 10.13.6

rbenv 1.1.1
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17]
Rails 5.2.2.1
Homebrew 2.0.5
Homebrew/homebrew-core (git revision 59f8; last commit 2019-03-23)

以前まではAWS Cloud9で開発していたので、補足情報などに不備があるかもしれません。
足りない情報などあれば追記いたします。

よろしくお願いいたします。

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

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

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

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

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

guest

回答2

0

Gemfile の
gem 'sqlite3', '~> 1.3.6'

gem 'sqlite3', '~> 1.4.0' に変更したら動作しそうに思えます。

投稿2019/03/24 11:06

YakumoSaki

総合スコア2027

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

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

0

gem 'sqlite3', '~> 1.3.6'

に変更して保存しましたら bundle install を実行してインストールを行ってからコンソールの起動を行ってみてください。

投稿2019/03/23 12:55

ykp_yk

総合スコア654

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

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

退会済みユーザー

退会済みユーザー

2019/03/24 00:52

ykp_yk様、ご回答ありがとうございます。 記載されている方法を試したのですが、依然としてエラーが発生してしまいました。 エラー文に変化はありませんでした。
ykp_yk

2019/03/24 01:03

お2つご回答ください。 1. Gemfile.lock のsqlite3の行はどのようになっていますか? 2. エラーに変化がないということでしたが、rails cを行った直後のエラーメッセージを3行ほど共有してください。 尚、bundle installやrails cを行ったディレクトリが正しいものかという点も確認してみてください。 違うアプリの変更していないディレクトリで行ってしまっているという可能性もございます。
退会済みユーザー

退会済みユーザー

2019/03/24 02:26

お返事ありがとうございます。 質問に回答させていただきます。 1. Gemfile.lock の sqlite3 sqlite3 (~> 1.3.6) となっております。 2. rails c の直後のエラーメッセージ3行 Running via Spring preloader in process 52117 Traceback (most recent call last): 50: from -e:1:in `<main>' となっております。 また、最終の4行は、 1: from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require': dlopen(/Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError) Referenced from: /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle Reason: image not found - /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle となっております。 ディレクトリも確認しましたが、問題ありませんでした。 rails s や rails g controller は問題なく動作するのですが、rails c はエラーが出てしまいます。 何か考えられる問題点が少しでもあれば指摘していただけると嬉しいです。
退会済みユーザー

退会済みユーザー

2019/03/24 02:29

Spring preloader が原因かと思い ps aux | grep spring をして、該当の PID を kill したのですが、 やはり同じエラーが出てしまいます。
ykp_yk

2019/03/24 02:32

> rails c の直後のエラーメッセージ3行 それはエラー内容が変わっていませんか? 以前は以下であったはずです。 /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError) from /Users/gotchryu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<main>' 状況が変わっていると思いますのでエラー内容をしっかり確認して問題がありそうな行を共有してください。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問