Rails3 rails console crashes throwing error - ruby-on-rails-3

I am trying Rails 3 and I am using RVM to manage the ruby versions. Using RVM I had installed ruby versions 1.8.7, 1.9.1 and 1.9.2.
When I do "rails console" I am getting the following error and console isn't starting:
/home/syed/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
from /home/syed/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /home/syed/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:3:in `require'
from /home/syed/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/syed/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta4/lib/rails/commands.rb:20:in `require'
from /home/syed/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta4/lib/rails/commands.rb:20:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Since I don't require 1.9.1 any more to work with Rails 3, I un-installed it using the following command:
rvm uninstall ruby-1.9.1
Still rails console crashes. Am I doing something wrong?

I am using Ubuntu 10.04 and RVM to manage different ruby installations.
I had to do:
rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 -C --with-readline-dir=/home/syed/.rvm/usr/
following the instructions here:
http://rvm.beginrescueend.com/packages/readline/ and with help from
Sutto at #rvm irc.freenode.net

Related

Rails console uninitialized constant MiniTest::Test (NameError) error

I use Rails. 3.2.16, with Rspec.
Recently when I run rails console I get the following error:
.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:28:in `const_missing': uninitialized constant MiniTest::Test (NameError)
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:4:in `<module:Test>'
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:3:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/test_case.rb:1:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/console/app.rb:2:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:312:in `initialize_console'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:152:in `load_console'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/console.rb:27:in `start'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/console.rb:8:in `start'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
When I run rails server there are no problems.
Since I use Rspec, I don't have minitest in my Gemfile. However when I run gem list I can see:
minitest (5.3.3, 5.3.2, 4.7.5, 4.3.2)
And I am not sure why this suddenly happens.
Additional note
#user3364461 may have a related issue:
With RVM and last bundler (1.6.2) ruby 2.1.1, and rails 4.1. Happen
when I've updated some gem (Axlsx-rails, minitest, arel) If I force
minitest 5.3.2, it's the same bug with arel :
Could not find minitest-5.3.3 in any of the sources Run bundle install
to install missing gems.

Ruby on Rails + PostgreSQL app fails to start on AWS EC2. Error is: "cannot load such file -- pg_ext (LoadError)"

I began by installing all these dependencies:
sudo yum install ruby19 ruby19-devel gem rubygems19-devel make gcc postgresql9 postgresql9-devel postgresql9-server
Then I switch to the root user and I run
bundle install
and I get the green success message:
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
However, when I cd to the dir and run
rails s -p80
it I get all this and it fails to start (I'm still root because bind won't work to port 80 if I'm not root):
/usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- pg_ext (LoadError)
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/share/gems/gems/pg-0.14.0/lib/pg.rb:4:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
from /home/user/TransForm/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Perhaps there is an easy way to just deploy it correctly from the begining instead of messing around with error craps? I need PostgreSQL. This app works everywhere except this AWS EC2 instance, so I know my Gemfile is correct. Any clues would help.
open irb & type require "pg" does it work? if not, then check that pg_ext exists in /usr/local/share/gems/gems/pg-0.14.0/lib/ directory. you can install manually postgresql gem manually, using
gem install pg
If this still doesn't work, ensure that you are using latest version of ruby & latest version of rubygems using gem environment command.if its the older version, you can install latest ones using rvm
use gem pg
than
bundle install
bundle update
please not use any version of pg
I face this error and solved by this

Incorrect MySQL client library version

I created a new rails project calling
rails new simple_cms
Then when in the directory I run
rails s
I get the follow errors
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l
ib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This
gem was compiled for 6.0.0 but the client library is 5.5.24. (RuntimeError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler.rb:119:in `require'
from c:/development/ruby/simple_cms/config/application.rb:7:in `<top (re
quired)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `block in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `tap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have seen other people with this error but they tend to be linux users and I am running windows. I have attempted to reinstall both rails (railsinstaller.org) and mysql 5.5. I have used both the 32bit version as well as the 64bit version
There seem to be several questions on here already about this. Did you try their solutions?
Probably the most clear is this:
mysql2 gem compiled for wrong mysql client library
The pertinent part is here:
At the time of building this gem, the necessary DLL files where available
in the following download:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin
This will remove the gem and its dependencies. Then reinstalling will re-compile itself and all dependencies.
gem uninstall mysql2
bundle install
I had this error in a new project I was working on which suddenly stopped working in a windows machine that already had working rails projects, so it was clearly not an installation problem.
What caused the problem was a bundle update command, which decided to redownload mysql2 gem (for unknown reasons) and ignored my Gemfile line gem 'mysql2', '~> 0.2.6'.
The problem was that bundle update got mysql version 0.2.18, as shown in Gemfile.lock, in the following line:
mysql2 (0.2.18-x86-mingw32)
I'm note sure what the symbol means, but I replaced the following line in my gemfile
gem 'mysql2', '~> 0.2.6'
for
gem 'mysql2', '0.2.6'
And now everything works fine, including bundle update.

rails and gem commands give error

when I run any rails specific command in the console it gives me an error. For instance, i tried
rails -v then it gives me error
/usr/local/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb:194:in `each': rehash occurred during iteration (RuntimeError)
from /usr/local/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb:194:in `<module:RbConfig>'
from /usr/local/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb:5:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:31:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/local/bin/rails:9:in `<main>'
The same happens for gem commands. Ruby is working fine.
Please Help. Thanks in Advance.
Not sure if that is the problem but according to the rails website, they only support ruby 1.8.7 or 1.9.2 .
and it seems you got 1.9.1.
The error message is showing that when you run rails, it is using 1.9.1. Per Wissam's comment, not sure if the ruby version is the problem, but you definitely need to make sure you are running on 1.9.2 before troubleshooting any further.
Did you install RVM? If so, have you set the default ruby? Try typing "rvm info" at the prompt. If you have RVM installed, it will print out a bunch of useful info about your ruby version. If you don't, it will say command not found. If you do have it, then you can select a different ruby version using "rvm use 1.9.2".
If you don't have RVM installed, then there are probably two versions manually installed on your host, and you'll need to figure out why rails is using 1.9.1.
In any case, I highly recommend using RVM. https://rvm.io.

Unable to get Postgresql database to work with Ruby on Rails 3

Environment
Windows 7 64 bit
Ruby 1.8.7
Rails 3.0.0
pg AdminIII
PostgreSQL 9.0.3
Cygwin
Gemfile
http://i54.tinypic.com/27yzxv4.png
Database Config
http://i53.tinypic.com/288b7ma.png
Steps I have taken
I tried addding "gem 'postgres-pr', :require => 'pg'" to the gemfile
Have tried installing multiple variations of the postgres gem,
postgres-pr
pg
ruby-pg
I continually get this error when trying to run rake db:migrate
rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Been at this for a couple days, really need some help. Thanks in advance!
You need to specify the correct platform for the gem. In my Gemfile, I have:
group :development, :test do
gem 'pg', :platforms => :mingw
end
(The group is there because I deploy to a Unix box, where the platform is obviously different). I seem to remember that I also needed the DevKit for this to work.
You need to install pg and add to your Gemfile
gem 'pg'
You may need to upgrade your version of Rails to 3.0.1 - 3.0.9 and also run gem install pg. Then just for good measure re-run bundle install.