Rails console is not working - rails c - ruby-on-rails

I've reinstalled the Ruby version a bunch of times, but I couldn't find why, when I go to the terminal and type rails c, it throws this error:
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /Users/cleytonmessias/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/completion.rb:9:in `<top (required)>'
from /Users/cleytonmessias/.rvm/gems/ruby-2.0.0-p247#trustvox/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `require'
from /Users/cleytonmessias/.rvm/gems/ruby-2.0.0-p247#trustvox/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/cleytonmessias/.rvm/gems/ruby-2.0.0-p247#trustvox/gems/railties-4.0.3/lib/rails/commands.rb:51:in `require'
from /Users/cleytonmessias/.rvm/gems/ruby-2.0.0-p247#trustvox/gems/railties-4.0.3/lib/rails/commands.rb:51:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I'm on Mac OSX Mavericks, Ruby-2.0.0-p247 and Rails 4.

I finally found a reference that helped me.
Using this link:
brew install readline
brew link readline
I went to file ~/.rvm/user/db and add the following line: ruby_configure_flags=--with-readline-dir=/usr/local/opt/readline
rvm reinstall 2.0.0-p247 --with-openssl-dir=/usr/local
Now when I type rails c it's working again :)

Related

My error when I setup rails with M1 and ruby 3.1.2?

I am trying to setup Rails and here is my problem.
My ruby version is 3.1.2(when I checked by command ruby -v)
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
But when I ran some codes like rails -v or rails -s, it always gave me this error
/Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': incompatible library version - /Users/anhbui/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/bootsnap.bundle (LoadError)
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/compile_cache/iseq.rb:3:in `<top (required)>'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/compile_cache.rb:16:in `require_relative'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/compile_cache.rb:16:in `setup'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap.rb:55:in `setup'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap.rb:97:in `default_setup'
from /Users/xxx/.gem/ruby/3.1.2/gems/bootsnap-1.14.0/lib/bootsnap/setup.rb:5:in `<top (required)>'
from /Users/xxx/Desktop/Rails/freelancer/config/boot.rb:4:in `require'
from /Users/xxx/Desktop/Rails/freelancer/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
So, how can I fix this one ?
My setup is
ruby 3.1.2
yarn 1.22.19
node 19.0.1
rails 6.1.x (maybe)
Thank you in advance!
Not sure what is the bug here but I faced the same issue and I solved it by completely uninstalling brew and reinstalling it back.
I got the suggestion from here: https://github.com/Shopify/bootsnap/issues/352

Rails error : active_support/core_ext/string (LoadError)

I installed Spree commerce for a website I'm making and needed to upgrade my Ruby version to 2.3.0 I've installed rvm and made the 2.3.0 the default ruby version to use.
I've re-installed Rails and Bundler but when I try to make to add the spree gem to my file using this formula:
spree install --auto-accept
then I get this error :
/Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- active_support/core_ext/string (LoadError)
from /Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/steph/.rvm/gems/ruby-2.3.0/gems/spree_cmd-3.0.8/lib/spree_cmd/installer.rb:2:in `<top (required)>'
from /Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/steph/.rvm/gems/ruby-2.3.0/gems/spree_cmd-3.0.8/lib/spree_cmd.rb:13:in `<top (required)>'
from /Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/steph/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/steph/.rvm/gems/ruby-2.3.0/gems/spree_cmd-3.0.8/bin/spree:2:in `<top (required)>'
from /Users/steph/.rvm/gems/ruby-2.3.0/bin/spree:22:in `load'
from /Users/steph/.rvm/gems/ruby-2.3.0/bin/spree:22:in `<main>'
from /Users/steph/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/steph/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
I'm really not sure what to do, i've tried re-installing bundler and rails et spree but nothing different.
I've been following these instructions : https://guides.spreecommerce.com/developer/getting_started_tutorial.html
Can anyone help me with this error? Thanks in advance!

Rails console not working even after updates

I am trying to run rails console. I have tried everything suggested on SO. I have libreadline-6 installed. My ruby version is 2.1.1 and irb is 0.9.6.
/home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Any suggestions?
Also, I am using rbenv to manage my ruby versions.
You need to install libreadline and also the -dev package and then you need to recompile ruby. When your using rvm you should always run
rvm requirements
first and then download and compile ruby. If your using rvm then you can run
rvm reinstall <version>
to do this.
// Also see: http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/

Ruby installation missing psych, suggests reinstall of libyaml and ruby, and still have image not found? RailsTutorial

When using this command in the middle of my RailsTutorial ( on my laptop setup) :
rvm use 2.0.0#railstutorial_rails_4_0 --create --default
I receive the following errors:
laptop:rubygems-1.8.25 USER_NAME$ rvm use 2.0.0#railstutorial_rails_4_0 --create --default
Using /Users/USER_NAME/.rvm/gems/ruby-2.0.0-p451 with gemset railstutorial_rails_4_0
/Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/yaml.rb:4:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/x86_64-darwin13.1.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/x86_64-darwin13.1.0/psych.bundle
Reason: image not found - /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/x86_64-darwin13.1.0/psych.bundle
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/psych.rb:1:in `<top (required)>'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/yaml.rb:5:in `<top (required)>'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems.rb:600:in `load_yaml'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/config_file.rb:314:in `load_file'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/config_file.rb:191:in `initialize'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `new'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `do_configuration'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/gem_runner.rb:46:in `run'
from /Users/USER_NAME/.rvm/rubies/ruby-2.0.0-p451/bin/gem:21:in `<main>'
I've reinstalled libyaml, and reinstalled ruby, and it all returns back to these errors. No matter what I do, I always end up back at this list of errors.

Rails console doesn't work

I installed ruby 2.0.0 and rails 4.0.0 on my Opensuse but rails console doesn't work.
I have this error message:
/home/zellou_i/.rubies/ruby-2.0.0-p247/lib64/ruby/2.0.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/zellou_i/.rubies/ruby-2.0.0-p247/lib64/ruby/2.0.0/irb/completion.rb:9:in `<top (required)>'
from /home/zellou_i/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:3:in `require'
from /home/zellou_i/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/zellou_i/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:53:in `require'
from /home/zellou_i/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:53:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I don't understand, I installed readline but he can't load it.
Ruby needs to be compiled with readline-support. Make sure you install libreadline6 and its dev headers (debian-specific packages, adapt to suse) and then recompile your ruby.

Resources