How to open Rails console

rails
ruby

#1

I’m trying to work alongside a tutorial and I need to open the Rails Console. How do I access it, I’ve CD’d to my application, and I’ve tried rails console and rails c. None of it worked, I want the IRB console. Instead, I got this at first.


#2

just wonder any error messages after entering the command?


#3

IRB console is different from the Rails console. If you want to open interactive Ruby console just type irb in the terminal.


#4

I just get this
dawnofkali:~/workspace/SinsMedia rails console /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- test/unit/testcase (LoadError) from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `block in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/test_case.rb:1:in `<top (required)>' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `block in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/console/app.rb:2:in `<top (required)>' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `block in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/application.rb:312:in `initialize_console' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/application.rb:152:in `load_console' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands/console.rb:27:in `start' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands/console.rb:8:in `start' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands.rb:41:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' dawnofkali:~/workspace/SinsMedia rails c
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require': cannot load such file -- test/unit/testcase (LoadError) from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:inblock in require’
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in load_dependency' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:inrequire’
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/test_case.rb:1:in <top (required)>' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:inrequire’
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in block in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:inload_dependency’
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/console/app.rb:2:in<top (required)>‘
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:inblock in require’
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in load_dependency' from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:inrequire’
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/application.rb:312:in initialize_console' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/application.rb:152:inload_console’
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands/console.rb:27:in start' from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands/console.rb:8:instart’
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-3.2.18/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire’
from script/rails:6:in `’


#5

Would you mind posting your gem file?
and also post your Ruby version by entering which -a ruby and ruby -v


#6

Here is my gemfile loc
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.18)
actionpack (= 3.2.18)
mail (~> 2.5.4)
actionpack (3.2.18)
activemodel (= 3.2.18)
activesupport (= 3.2.18)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.18)
activesupport (= 3.2.18)
builder (~> 3.0.0)
activerecord (3.2.18)
activemodel (= 3.2.18)
activesupport (= 3.2.18)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.18)
activemodel (= 3.2.18)
activesupport (= 3.2.18)
activesupport (3.2.18)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
bcrypt (3.1.11)
builder (3.0.4)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
devise (3.5.7)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.6.0)
hike (1.2.3)
i18n (0.7.0)
journey (1.0.4)
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
multi_json (1.11.2)
orm_adapter (0.5.0)
polyglot (0.3.5)
rack (1.4.7)
rack-cache (1.6.1)
rack (>= 0.4)
rack-ssl (1.3.4)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (3.2.18)
actionmailer (= 3.2.18)
actionpack (= 3.2.18)
activerecord (= 3.2.18)
activeresource (= 3.2.18)
activesupport (= 3.2.18)
bundler (~> 1.0)
railties (= 3.2.18)
railties (3.2.18)
actionpack (= 3.2.18)
activesupport (= 3.2.18)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (11.1.2)
rdoc (3.12.2)
json (~> 1.4)
responders (1.1.2)
railties (>= 3.2, < 4.2)
sass (3.4.22)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.48)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
warden (1.2.6)
rack (>= 1.0)

PLATFORMS
ruby

DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
jquery-rails
rails (= 3.2.18)
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)

BUNDLED WITH
1.11.2

My regular gem file
source ‘https://rubygems.org

gem ‘rails’, ‘3.2.18’

Bundle edge Rails instead:

gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem 'sqlite3’
gem ‘devise’

Gems used only for assets and not required

in production environments by default.

group :assets do
gem ‘sass-rails’, '~> 3.2.3’
gem ‘coffee-rails’, ‘~> 3.2.1’

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem ‘therubyracer’, :platforms => :ruby

gem ‘uglifier’, '>= 1.0.3’
end

gem ‘jquery-rails’

To use ActiveModel has_secure_password

gem ‘bcrypt-ruby’, ‘~> 3.0.0’

To use Jbuilder templates for JSON

gem ‘jbuilder’

Use unicorn as the app server

gem ‘unicorn’

Deploy with Capistrano

gem ‘capistrano’

To use debugger

gem ‘debugger’

The which -a ruby command
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby
/usr/bin/ruby
That’s all I got.

Then for ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]


#7

I am able to reproduce your problem:

For Rails 3.2.18, you are better to add the following item in your gem file under your rails app:
gem ‘test-unit’

Then, of course, bundle install and bundle update
Seems ok now:

As your are running a tutorial, I strongly suppose you strictly follow the tutorial’s Rails version. Otherwise, you may face other version compatible problems if you keep going on.

Happy Coding!


#8

You’re a genius! Thanks so much man! :smiley: