Arel Deprecation Warning when running rake db:create - activerecord

I'm trying to create an app in Rails 3.1 with mysql2 v 0.2.6. When running rake db:create, I get the following error:
DEPRECATION WARNING: Arel::Visitors::VISITORS is deprecated and will be removed.
Database adatpers should define a visitor_for method which returns the appropriate
visitor for the database. For example, MysqlAdapter.visitor_for(pool) returns
Arel::Visitors::MySQL.new(pool). (called from mon_synchronize at
c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201)
I can access the MySQL monitor, so the gem appears to be installed correctly. What else could be going on here?
Thanks!

Try updating your msql gem.
In ./Gemfile
gem require 'mysql2', '~> 0.3.6'
bundle update mysql2

use the below specified version in gemfile.
gem 'mysql2', '~>0.3.10'
then run
bundle install

Related

How to update ruby gem dependency? Must I rebuild it? How?

I have a gem already installed locally, and I wanna add a new dependency into it. I worked with below steps:
Open the gem installation folder as below:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0
Add new dependency below into gemspec file (nesta.gemspec)
s.add_dependency('stacktracer', '>= 0.0.1')
Append gem 'stacktracer' into Gemfile
Add require "stacktracer" into Rakefile
Run command bundle update nesta
Run command bundle install
Check Gemfile.lock, I already found the new dependency like below:
I have next dependencies:
DEPENDENCIES
debugger
mr-sparkle (>= 0.0.2)
nesta!
rack-test (= 0.6.1)
rspec (~> 2.14.0)
**stacktracer**
test-unit (= 1.2.3)
webrat (~> 0.7.3)
But when I met two problems here:
run command gem dependency nesta, I did not find stacktracer dependency list.
I added require "stacktracer" into app.rb, then run the application, it failed due to below error:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0/lib/nesta/app.rb:4:in `require': cannot load such file -- stacktracer (LoadError)
Could any one help me to tackle the problems? Is there any approach that could manage to update gem dependency successfully?
You are not supposed to edit the unpacked gems under .../rvm/gems/ruby-2.1.0/gems. If you need to update the alien gem, you are to follow this approach:
Fork the gem source at github
Clone the repo to your local drive
Update whatever you want + update version
Set the dependency in your Gemfile to either use unpacked version or your git:
gem 'nesta', :path => '.../nesta.git'
gem 'nesta', :git => 'git://...'
Don’t forget to eliminate the original gem presence over your system. Hope it helps.

heroku run rake db:create fails with Could not find gem 'pg..., but the database is mysql2 (not postgresql)

I receive the following error when I run heroku run rake db:create:
Running `rake db:create` attached to terminal... up, run.6027
Could not find gem 'pg (>= 0.11.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
In the config/database.yml I'm using the default mysql2 database:
production:
adapter: mysql2
database: redmine
host: localhost
...
development:
adapter: mysql2
...
test:
adapter: mysql2
...
So I guess 'pg (>= 0.11.0) ruby' does not need to be installed. Am I wrong?
I'm using Windows XP. It is the first time I use Ruby.
UPDATE 1
I forgot to say bundle install finished correctly without errors.
On the other hand, Gemfile has the following code:
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
...
when /postgresql/
gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
...
So again, I guess it should never enter in when /postgresql/ when the command heroku run rake db:create is executed. Am I right?
See the discussion above... This is a Heroku application and it needs a database configured or it is going to try and force Postgres as a dependency to help you out.
You need to do bundle install before running the rake task for db creation and fulfill all gem dependencies. This is required even though you are using mysql and not postgres because the 'pg gem' is specified in the Gemfile and you have to make sure that all gem dependencies in your Gemfile are made available to your application by running the bundle install commmand.
As in your case you are using mysql, you do not require the 'pg gem' and can remove or comment it in the Gemfile.

Unresolved specs during Gem::Specification.reset:

When launching Guard, I'm getting this output:
$ guard
WARN: Unresolved specs during Gem::Specification.reset:
lumberjack (>= 1.0.2)
ffi (>= 0.5.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
What does this mean, and how do I fix it?
Contents of Guardfile:
guard 'livereload' do
watch(%r{.+\.(css|js|html)$})
end
guard 'sass', :input => 'css', :style => :compressed, :extension => '.min.css'
I was seeing this issue by just running RSpec on its own. From what I understand, this means that you have more than one version of the listed gems installed on your system, and RSpec is unsure which one to use. After uninstalling older version of the gems, the warnings went away.
You can try:
gem cleanup lumberjack
Or:
gem list lumberjack
gem uninstall lumberjack
If you're using Bundler, you can try bundle exec guard (or in my case bundle exec rspec).
Using the following command solved it for me:
bundle clean --force
See guard-and-unresolved-specs for more info
Use Bundler. Call bundle exec guard, not guard.
FYI:
gem cleanup
worked for me.
$ gem cleanup
Cleaning up installed gems...
Attempting to uninstall builder-3.2.2
Successfully uninstalled builder-3.2.2
Attempting to uninstall amatch-0.3.0
Successfully uninstalled amatch-0.3.0
Attempting to uninstall tins-1.12.0
Successfully uninstalled tins-1.12.0
Clean Up Complete
This worked for me:
bundle clean --force
then
bundle install
to reinstall gems.
I use gem list gem-name; gem uninstall gem-name to clean the gem one by one because of the dependency. After that, the error does not show again.
add
'bundle exec'
before your command.
I use ruby 2.4 and got the same problem when deploying jekyll on windows, it fixed.
I was getting this message while running Rspec within a Guard plugin gem, using bundle exec rspec. It turned out to be a missing line in the gemspec file:
$:.push File.expand_path("../lib", __FILE__)
This line is normally at the top of the file (in many of the gems I have recently been working in) and I had commented it out to see why.
Remember, if you want to use guard, you have to add gem guard to Gemfile.
group :developement, :test do
gem 'guard'
end
Then, run
bundle install
I hope this can help you.
If anyone has come this far and still hasn't found the answer I leave you with this. gem update --system. I tried all of these other answers to no avail. Hopefully this works for you.
Try gem uninstall <gem>
and it will remove all younger versions of gem.
You will then be asked
"If you remove this gem, these dependencies will not be met. Continue
deleting? [YN]"
Select the answer
"no"
to leave the latest version of gem and all dependencies remain valid.

RVM, Merb, Rake and RSpec

I am currently running ruby-1.9.1 installed via RVM. I have been looking at using Merb, but when I try and run it I get this error:
sam#shiny-dev:~/Projects/mojo$ rake db:migrate
(in /home/sam/Projects/mojo)
Merb root at: /home/sam/Projects/mojo
/home/sam/.rvm/gems/ruby-1.9.1-p378#merb/gems/dm-validations-1.0.0/lib/dm-validations.rb:33: warning: already initialized constant OrderedHash
Loading init file from ./config/init.rb
Loading ./config/environments/development.rb
rake aborted!
no such file to load -- spec/rake/spectask
/home/sam/Projects/mojo/Rakefile:24:in `require'
(See full trace by running task with --trace)
I have installed rspec, but even in IRB I cannot require 'spec/rake/spectask' unless I also install rspec-rails (which I have now done).
Any ideas where I could even start?
Cheers,
Sam
I had the same problem with this on Rails 2.3.5. I ended up having to uninstall RSpec 2.0 and install RSpec 1.3.0 instead.
After 2 weeks I finally figured it out!
Edit your Gemfile and add the line:
gem "rspec", :require => "spec"
and you're away!

rake aborted help

i don't really know what ruby,gems, or ror is, my objective is make this web application run in my local and after that push it on live. the problem is, when I perform this command
rake db:migrate
i am getting an error saying
rake aborted! Could not find RubyGem rack (~) 1.0.1)
what should I do ? please help me
It's telling you that you need a specific version of the Gem called "rack". You can install it by doing:
gem install rack -v=1.0.1
This will only install it to your local gem directory. If you want to install it globally (which is recommended for production environments), simply do:
sudo gem install rack -v=1.0.1
This will prompt you for the administrator password as usual.
You need to write this in your command prompt:
gem install rack

Resources