mysql2 adapter issues in installing Redmine on Fedora 17 - ruby-on-rails

I was trying to install Redmine on Fedora 17, following this
Until this step:
RAILS_ENV=production rake db:migrate
It throws an error saying:
rake aborted!
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (cannot load such file -- mysql2/mysql2)
/var/www/redmine/lib/plugins/acts_as_activity_provider/init.rb:2:in `block in <top (required)>'
/var/www/redmine/config/initializers/00-core_plugins.rb:12:in `eval'
/var/www/redmine/config/initializers/00-core_plugins.rb:12:in `block in <top (required)>'
/var/www/redmine/config/initializers/00-core_plugins.rb:2:in `each'
/var/www/redmine/config/initializers/00-core_plugins.rb:2:in `<top (required)>'
/var/www/redmine/config/environment.rb:14:in `<top (required)>'
Tasks: TOP => db:migrate => environment
which is weird, because I have already installed mysql2 with bundle:
bundle show
...
* mysql2 (0.3.11)//***which is right in the bundle show list***
...
my database.yml is like:
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: 123456
encoding: utf8
others my be involved
ruby 1.9.3p327 (2012-11-10 revision 37606) [i386-linux]
Rails 3.2.8
gem 1.8.24
mysql Ver 14.14 Distrib 5.5.28, for Linux (i686) using readline 5.1
Redmine 2.1.3
I have found some related questions by google, like:http://www.redmine.org/issues/11071#note-4
And I do as they said, adding symlink
ln -s /usr/local/share/gems/gems/mysql2-0.3.11/lib /usr/share/ruby/mysql2
Then exactly as posted in the page:
rake aborted!
uninitialized constant Mysql2::Client::REMEMBER_OPTIONS
I tried to do what is posted in #6 but it didn't work for me.
Is this the right way to solve my problem, and what should I do with the second bug.

Add gem 'mysql2' in your gemfile and run bundle install and then do RAILS_ENV=production rake db:migrate

If you're using Fedora's ruby, try:
yum install ruby-mysql
If you're using RVM or any other similar tool, install mysql's development packages, and then reinstall the ruby mysql gem.
yum install mysql-devel

> add gem "minitest" into Gemfile
> gem list | cut -d" " -f1 | xargs gem uninstall -aIx
> yum erase rubygem-activesupport-3.0.11-5.fc17.noarch
> yum install rubygem-bundler
> bundle install
> then other steps, this works!!
for details, please refer to this
thanks!!

Related

Not Able to install gems in Rails 2.3.8 & Ruby 1.8.7?

First Of all Thanks in advance :)
When I try to install the gem in rails application so it shows error like below.
$ rake gems:install
Invalid gemspec in [/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/specifications/carmen-1.0.0.beta2.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0x7f630b62a000> 2.6.1"]
rake aborted!
undefined method `source_index' for Gem:Module
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/initializer.rb:298:in `add_gem_load_paths'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/initializer.rb:132:in `process'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
/home/aspireedge/Aspiree/pyromaniac/config/environment.rb:16
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/tasks/misc.rake:4
/home/aspireedge/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.8/lib/tasks/gems.rake:17
Tasks: TOP => environment
(See full trace by running task with --trace)
when I try to update gem
$ gem update --system
Latest version currently installed. Aborting.
I aslo try to remove gem with rvm gemset empty
but still got error
Try upgrade your RubyGems and remove and install again the carmen gem:
gem update --system
gem uninstall carmen
gem install carmen
There is a PPA with up-to-date versions of Ruby 2.x for Ubuntu 14.04+:
$ sudo apt-get remove rubygems
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.4
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux-gnu]

gem install rails -v 4.2.4 Failed to install

I receive the following error message when running this command:
gem install rails -v 4.2.4
This is the error:
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:5: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/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
Reason: image not found - /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/psych.rb:7:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:6:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:628:in `load_yaml'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:326:in `load_file'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:198:in `initialize'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `new'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:40:in `run'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/bin/gem:21:in `<main>'
Please Help - this is causing me nightmares
It seems your ruby installation is missing psych (for YAML output).
Install libyaml with Homebrew: http://brew.sh; then try gem install rails -v 4.2.4
$ brew info libyaml
libyaml: stable 0.1.6 (bottled)
YAML Parser
http://pyyaml.org/wiki/LibYAML
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libyaml.rb
==> Options
--universal
Build a universal binary
$ brew install libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
REINSTALL RUBY
If the above solution doesn't work for you, reinstall Ruby from scratch with rvm or rbenv,
1) Try the instructions on this accepted answer: https://stackoverflow.com/a/38194139/1076207
—OR—
2) Remove all rvm files, then reinstall rvm: https://stackoverflow.com/a/38158619/1076207
—OR—
3) Remove all rvm files, then install rbenv: https://stackoverflow.com/a/38194231/1076207
After using one of the three options above, use http://bundler.io to install Rails:
$ mkdir ~/Documents/Repo
$ cd ~/Documents/Repo
$ gem install bundler
[…]
$ bundle init
Writing new Gemfile to /Users/username/Documents/Repo/Gemfile
$ echo "gem 'rails', '4.2.4'" >> Gemfile
$ bundle install
[…]
$ bundle exec rails new project_name
[…]
$ cd project_name
Personally, I recommend 3) switch to rbenv—I did.
The error itself clearly says that you should install libyaml first and then re-install your ruby. You can do it by running following commands.
sudo apt-get install libtool
rvm package install libyaml
rvm reinstall ruby-2.3.0
for more reference please see this answer

rake cannot load such file (LoadError)

I'm having a strange rake error when I try to install, here is what it says
$ rake bundle_install
/usr/local/bin/rake:23:in `load': cannot load such file -- /usr/share/rubygems-integration/1.9.1/gems/rake-10.0.4/bin/rake (LoadError)
from /usr/local/bin/rake:23:in `<main>'
When I try to navigate to the directory, i find nothing:
$ ls /usr/share/rubygems-integration/1.9.1/
specifications/
Ruby versions:
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
Why it's trying to load the wrong version and how I could fix this?
you can try:
bundle update rake
the same issue was resolved here: Ruby rake loaderror - bundle exec rake not working
Look for the gemspec file.
Your version of rake specified at the gemspec file must match the rake version you are using.
Try: bundle update rake. This will install a new version of rake. Open your gemspec file and update the rake version.
I had this:
spec.add_development_dependency "rake", "~> 10.0"
And I have changed to:
spec.add_development_dependency "rake", "~> 11.0"
run bundle update rake again:
Resolving dependencies...
Using rake 11.3.0 (was 10.5.0)
After that, it will work.
It seems that you need to re-install ruby..Hopefully that might solve the problem.Had faced this issue previously.Resolved by reinstalling ruby.
Perhaps it helps somebody. I had same error, but with rails, instead of rake.
I have got such error while installing redmine.
$ sudo bundle exec rails server webrick -e production
bundler: failed to load command: rails (/usr/local/bin/rails)
LoadError: cannot load such file -- /usr/share/rubygems-integration/all/specifications/bin/rails
/usr/local/bin/rails:23:in `load'
/usr/local/bin/rails:23:in `<top (required)>'
This is my solution:
$ sudo bundle update rails
This should work in the latest version.
# Rakefile.rb
require 'bugsnag/integrations/rake'

Ruby on Rails - Lynda - Generating a Controller and View, Error on 'Rails Generate' Command

I'm new to Ruby on Rails and was following Lynda's Ruby on Rails essential training guide videos.
In the getting started set of videos, we are shown how the 'rails generator' command works. I have followed all the steps, but every time I type in '$ rails generate' I get the following error:
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:33:in `<module:Spring>'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
How do you suppose I get around this?
The answer is in the Error:
You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all`
Update with this:
gem install rubygems-update
Then run:
gem pristine --all
All should be well.
When I update
gem install rubygems-update
and then
gem pristine --all
it didn't work for me.
But answer from How to upgrade rubygems helped to fix issue, but after that for some reason I had to install rails again and install all gems.
Install rubygems-update
gem install rubygems-update
update_rubygems
gem update --system
run this commands as root or use sudo.
I am using ruby with rbenv so I could run those as normal user.
However, generating new rails site
rails new blog
Shows warning about old rubygems.
Warning: You're using Rubygems 2.0.14 with Spring.
Hmm. Checking the environment:
gem env
shows
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
which is no good. As suggested on the internets I run:
gem install rubygems-update
gem pristine --all
update_rubygems
I am not sure if gem pristine --all was needed, but it can't harm anything. Checking the update status now
gem env
shows
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
which is good. Calling
rails new blog
and everything went ok. No warning at all.

rails cannot load such file -- mysql2/mysql2 (LoadError)

I am newbie to ruby on rails i could not find the solution for this error:
rails s
/usr/local/share/gems/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /usr/local/share/gems/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/Harish/Documents/simple_cms/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
gem uninstall mysql2
gem install mysql2 --platform=ruby
delete the mysql2 gem directory in your rails specific bundle directory and copy paste this newly install mysql2 gem
For Rails 3.2.17 and Ruby 1.9.3-p448 and mysql2 0.3.11, running bundle update mysql2 updated to 0.3.15 and got rid of the error for me.
Ya, It's happening with new version(0.3.13) of mysql2 gem with rails 4.0.0. Deleting the bundle folder under vendor directory, and rerunning bundle install, update fixed this issue for me
cd {Your_RailsApp_Root}/vendor/
rm -rf bundle/
cd {Your_RailsApp_Root}
bundle install
bundle update
Do you have the mysql2 gem installed? Check that your gemfile has gem "mysql2" and then run bundle install from the root of your rails app. Also, ensure that you mysql downloaded in your development environment.
just downgrade the mysql2 version. In my case, I used '0.2.6' version and it worked for me.
gem 'mysql2', '0.2.6'
with ruby version 2.0.0 and gem version 1.8.25
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
from
https://gorails.com/setup/osx/10.14-mojave
I battled this for a day when running into it while trying to run bundle exec rake db:migrate after successfully bundle installing my project gems.
For me, mysql2 was trying to load a configuration file that didn't exist. I had already brew installed mysql on my system, and what mysql2 was looking for existed already in the mysql installation. I ran
gem install mysql2 -v 0.5.3 -- --with-mysql-config=/usr/local/Cellar/mysql#5.6/5.6.42/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
to point mysql2 to the correct configuration.
NOTE the version you have of mysql may be different and the version of the gem you want may also be different.
ALSO NOTE: the gem install path may be different than your bundle install path. You can also the gem to your bundle directory with
gem install --install-dir /path/to/bundle/directory
OR you can set gem options with your bundle build configuration:
bundle config --local build.mysql2 --with-mysql-config="/usr/local/Cellar/mysql#5.6/5.6.42/bin/mysql_config" --with-ldflags=-"L/usr/local/opt/openssl/lib" --with-cppflags=-"I/usr/local/opt/openssl/include"
Apple silicon M1:
gem install mysql2 -v '0.5' -- --with-opt-dir=$(brew --prefix openssl)
It work for me.
gem uninstall mysql2
sudo gem install mysql2
bundle
this solved my error:
[root#localhost cms]# su Harish
[Harish#localhost cms]$ bundle install
[Harish#localhost cms]$ rails s

Resources