uninitialized constant error in Rails connecting to MySQL after Ubuntu upgrade - ruby-on-rails

I've just upgraded Ubuntu from 11.10 to 12.04 and when I try to run a project locally in Rails 2.3.14 I'm getting this error:
uninitialized constant MysqlCompat::MysqlRes
Is there a way of fixing this easily?

You should re-install the gem you are using to connect to the database.
For example, if you are using mysql2 gem, then you can do:
gem uninstall mysql2
gem install mysql2
This will re-build the native extensions that the Ubuntu upgrade messed up.

While upgrading the gem sometimes get's messed up.
You don't need to uninstall it, just installing again is enough.
gem install mysql2
I've seen this happen with the mysql gem too.

Related

trouble installing postgresql for rails app

So I would like to deploy my rails app on heroku right? Wanna switch from sql3 to postgresql. Should be simple but I keep getting an error when trying to bundle with gem 'pg' in my gemfile. I used homebrew to install postgresql with all its native extensions before trying to bundle. Any ideas? I am on Mac OSX high sierra.
An error occurred while installing pg (1.1.3), and Bundler cannot
continue.
Make sure that gem install pg -v '1.1.3' --source 'https://rubygems.org/'
succeeds before bundling.
That's all I get for the error. Not helpful. I went ahead and uninstalled postrgresql that I installed locally to my machine from their website as well as with homebew. Gonna start from scratch. I haven't done this in years so any help would be appreciated!
I've run into this before where you attempt to install the PG gem, but postgres is not yet installed. Even if you install postgres after that, you'll still run into troubles (this has to do with required libraries not being available or not found). I would recommend uninstalling both, then installing Postgres first, then the PG gem. This is a common gotcha, unfortunately: Installing PG gem on OS X - failure to build native extension Also, I would recommend https://postgresapp.com/ if you continue to have trouble installing PG or having the gem not see your install properly.
After tons of research and trying everything, found an older question on stackoverflow from 2014. If you install postgresql with homebrew like I did, running the command ARCHFLAGS="-arch x86_64" gem install pg will install the gem if bundling or gem install pg don't work. Hope that helps other people who might be stuck like I was

Ruby on rails new app is not creating

I started to develop the new RoR web app and faced weird issue.
I wanted to create new app with Postgresql. So I installed the Postgres with brew and MacOS desktop app. And type rails new test-app --database=postgresql.
At this moment, I can't install bundles because there is certain
error.
An error occurred while installing pg (1.0.0), and Bundler cannot
continue.
Make sure that `gem install pg -v '1.0.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
run bundle exec spring binstub --all
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources
listed in your Gemfile.
Run `bundle install` to install missing gems.
So I can't start new app.
Is this an issue that is occurring because of the mismatch between ruby and postgres version?
And how can I create new app with postgres?
I am currently using Mac OS high Sierra, postgres 10.5, rails 5.2.1
Try to skip running Bundler: rails new test-app --database=postgresql --skip-bundle
Once you've generated your app, you'll still have to troubleshoot why pg ins't installing. The PG gem should install just fine as long as the database is there and your system can build the gem's native extensions, so my first guess is either Postgres isn't installed or it can't be found in your environment.
Either way, this does answer your question. Skip the bundle and voila - Rails will generate a new clean app for you.
I've posted some comments, but i already seen that it seems to be an error when installing postgresql via brew. It's not common, but it happens sometimes.
Here's a quick fix:
brew install libpqxx
Make sure to run also
brew update
and restart your PostgreSQL server via:
brew services restart postgresql
Also make sure to clean up brew:
brew cleanup
If the error is still there, post your Gemfile and your database.yml file as well.
Greetings!

no metadata found in activereocrd-3.2.9.gem when running bundle install in a rails 3.2.9

am a newbie in rails. working on Windows 7, 64 bits. Installed my environment through RailsInstaller. latest version ofcourse.
When creating a new project, (keeping the gem file as default) and having the bundle install run, am getting the error
gem::package::FormatError: no metadata found in
D:/RailsInstaller/Ruby1.9.3/bin/cashe/activereocrd-3.2.9.gem
and error occurrend while installing activerecord (3.2.9), and bubndler cannot continue.
Make sure that gem install activerecord -v '3.2.9' succeeds before building.
I tried to run the gem install activerecord..as instructed still bundle install does not work and i cannot run the rails server. (rails s)
When changing the rails version in the app gem file to 3.2.8 instead of 3.2.9 everything seems to work and the rails server runs succefully. What is wrong?
I uninstalled railsinstaller and all other leftover folders.
reinstalled railsinstaller. Problem solved.

Proper syntax for installing mysql2 gem pre-version 0.3.0 with MYSQL LIB and INCLUDE options on Windows 7

There must a million variations of this problem but I don't seem to be finding any answers.
I spent the afternoon looking for a way to install MYSQL 5.5 on my Windows 7, 64-bit machine and install the mysql2 gem. Finally I found Lukom's comment at the RORGUIDE blog and I was off and running with this code:
gem install mysql2 -- '--with-mysql-lib="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\include"'
So, this installs the 0.3.6 version of the mysql2 gem. Hooray! However, when I try to run the db:create I get the following error:
WARNING: This version of mysql2 (0.3.6) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
So I figure all I have to do is uninstall the gem and reinstall a version less that 0.3.0 and I am back on track. However, I cannot find the code to properly indicate the gem version AND my lib/include arguments. Here is my best attempt and the error:
gem install mysql2 --version "0.2.7" '--with-mysql-lib="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\include"'
invalid option: --with-mysql-lib=C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\lib
So I am at a loss. I don't want to upgrade to the Rails pre-release because I don't enjoy troubleshooting that much. I am sure this is a simple syntax error and I would appreciate anyone who can show me the correct command for both the version and lib/include arguments.
Thanks in advance,
Byron
Try this:
gem install mysql2 --version '0.2.7' -- --with-mysql-lib="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="C:\TEMP\msi\Files\MySQL\MySQL Server 5.5\include"

problem setting up rails 3 app with mysql2 0.2.11 and rake 0.9.2

I have a project with the following Gemfile.lock file
http://pastie.org/private/tfbnteruyahmwfhtt26ea , and when I do
rake db:create --trace,
I get the following error trace.
http://pastie.org/private/vz6gzalof9wywhzfbk0ixg
How can i fix this problem? Changing gem versions is not an option, since this file is already working with other developers.
Check database.yml to make sure you're using the mysql2 adapter instead of mysql.
If you're running Snow Leopard try to do the following
Uninstall mysql gem:
sudo gem uninstall mysql
Install gem with correct flags
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
P.S: Also check that you're running MySQL 5.1 and not 5.5 because there were some troubles with it so it is recommended to downgrade to 5.1.

Resources