Vagrant provision throws this error
Error executing action drop on resource 'mysql_database[database_name]'
LoadError
cannot load such file -- mysql2
My code snippet which throws the error is as follows
mysql_database node['mysql_database'] do
connection mysql_connection_info
action [:drop,:create]
end
My cookbook is installing mysql2 gem in the vagrant machine.
vagrant#ubuntu-14:~$ gem list --local
mysql2 (0.4.1, 0.4.0)
I couldn't figure out why is it still not able to load the mysql2 gem. Any help is appreciated.
Related
I'm trying to install mysql2 gem in my vagrant machine with chef solo. I am getting the following error
ERROR: mysql2_chef_gem_installer[default] (mysql2_chef_gem::default line 20) had an error:
Chef::Exceptions::RecipeNotFound: could not find recipe client for cookbook mysql
I have included the cookbook mysql and the dependencies are added in the metadata.rb
Following is the code snippet
mysql2_chef_gem_installer 'default' do
type 'mysql'
action :install
end
Could somebody explain what is it I am doing wrong ?
I'm trying to add a Test Kitchen to a Chef cookbook but am getting the error "Could not load the 'ssh' transport from the load path".
I have previously set up a Test Kitchen following the exact same steps without issue, but that was on a different machine.
I've tried running
gem install net-ssh
But that doesn't seem to fix the problem
Solved it.
I ran
gem list
Which gave the output
..
net-ssh (2.10.0.beta2, 2.9.2)
..
I then issued the command:
gem uninstall net-ssh 2.10.9.beta2
And got the output:
Select gem to uninstall:
1. net-ssh-2.10.0.beta2
2. net-ssh-2.9.2
3. All versions
Whereupon I selected option 1, the gem was removed and then running
kitchen list
Worked as expected
I was running into the same problem for Java SE Chef cookbook on Travis-CI with:
Chef Development Kit Version: 0.10.0
chef-client version: 12.6.0
berks version: 4.0.1
kitchen version: 1.5.0
Throwing this:
-----> Starting Kitchen (v1.5.0)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'ssh' transport from the load path. Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
I had to switch to Dokken to get it to work:
https://github.com/someara/kitchen-dokken
To fix:
Update .travis.yml to install kitchen-dokken:
/opt/chefdk/embedded/bin/chef gem install kitchen-dokken
And update .kitchen.docker.yml with:
transport:
name: dokken
provisioner:
name: dokken
verifier:
root_path: '/opt/verifier'
sudo: false
driver:
name: dokken
I note that there have been many other similar questions, but my context seems to be different.
Error
The following is the error I am getting, trying to run/restart a Rails Application (Redmine). Redmine was running fine, but there have been some server updates by the shared host, thus seeing these problems.
mysql2 is listed in the gem/bundle list. mysql2.so exists in the location it is looking for, and has the required (executable) permissions. Thank you any suggestions in addressing this issue.
Error message:
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (libruby.so.1.8: cannot open shared object file: No such file or directory - /home/test/gems/gems/mysql2-0.3.11/lib/mysql2/mysql2.so)
Exception class:
LoadError
Enviornment
# ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]
# rails -v
Rails 3.2.6
# gem -v
1.8.23
# mysql --version
mysql Ver 14.14 Distrib 5.5.34, for Linux (x86_64) using readline 5.1
#gem list
...
mysql2 (0.3.11)
...
#bundle show
...
mysql2 (0.3.11)
...
#vim database.yml
production:
adapter: mysql2
database: database_name
host: localhost
username: dbuser
password: dbpwd
encoding: utf8
Answer to this question solved my issue.
gem uninstall mysql2
bundle install
I am attempting to follow this Redmine setup tutorial. When I get to the point of starting the server, I type sudo rails server and I get the following error:
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)
The relevent section of my Gemfile reads:
....
if File.exist?(database_file)
database_config = YAML::load(ERB.new(IO.read(database_file)).result)
adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
if adapters.any?
adapters.each do |adapter|
case adapter
when /mysql/
gem "mysql", "~> 2.8.1", :platforms => [:mri_18, :mingw_18]
gem "mysql2", "~> 0.3.11", :platforms => [:mri_19, :mingw_19]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
...
and Gemfile.lock contains mysql2:
...
multi_json (1.5.0)
mysql (2.8.1)
mysql2 (0.3.11)
net-ldap (0.3.1)
...
and my database.yml file includes the following:
...
production:
adapter: mysql2
database: redmine
host: localhost
username: ****
password: ****
development:
adapter: mysql2
database: redmine_development
host: localhost
username: ****
password: ****
encoding: utf8
...
Running bundle install seems to succeed, but mysql2 is not listed in the output, which mysql2 returns nothing, and bundle show mysql2 returns Could not find gem 'mysql2' in the current bundle.
I have uninstalled and reinstalled the mysql2 gem, with apparent success each time.
I have read through descriptions of similar-sounding problems on other stackoverflow questions, but none of their solutions turned out to solve my problem.
You will get this error if mysql2 is not included in the Gemfile.lock file that's generated by bundle. While the Gemfile is used to manage dependencies, the lock file is what is actually loaded by the rails app.
That's a more verbose Gemfile than I have seen before (I'm not generally familiar with Redmine)- where is this from? It doesn't appear to be from the most recent stable source. If you know you'll be using mysql2, I don't think there's any reason you need your Gemfile to parse your database config. For whatever reason, it's not properly reading the database.yml file.
Try adding gem 'mysql2' outside any blocks or loops and run bundle again.
I've got a problem with running an additional gem under ubuntu 11.04. I installed spiceweasel via gem install - which put it in /var/lib/gems/1.8/gems/spiceweasel. When I try to run it, I get:
`require': no such file to load -- spiceweasel/version (LoadError)
The file is in /var/lib/gems/1.8/gems/spiceweasel-0.7.1/lib/spiceweasel/version.rb but cannot be loaded. This happens both with and without -rubygems.
How do I fix this?
It seems to be the same problem like here: Ruby: require 'irbtools' raises LoadError
The gem author published the gem with wrong permissions. You should contact the gem author.