Rails cannot generate model using mysql - mysql

Windows XP with installed MYSQL as a development machine, ruby 1.9.2p290 (2011-07-09) [i386-mingw32], Rails 3.1.0
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL S
erver 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\inc
lude"' (successfully installed gem mysql2)
rails new talk -d mysql (successfully created a new rails app called talk)
PROBLEM NOW STARTS:
C:\Sites\RP\talk>rails generate User
ERROR MESSAGE:
ruby.exe-Unable to Locate Component
This application has failed to start because libmysql.dll was not found. Re-installing the application may fix this problem.
COMMAND LINE ERROR MESSAGE:
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb
:9:in require': 126: The specified module could not be found. - C:/RailsInsta
ller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2/mysql2.so (Load
Error)
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/
lib/mysql2.rb:9:in'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:68:in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:66:in each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:66:inblock in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:55:in each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:55:inrequire'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler.rb:120:in require'
from C:/Sites/RP/talk/config/application.rb:9:in'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0
/lib/rails/commands.rb:21:in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0
/lib/rails/commands.rb:21:in'
from script/rails:6:in require'
from script/rails:6:in'

http://www.ruby-forum.com/topic/150580 has the answer. for some reason I need to:
1/ gem install mysql
2/ copy the libmysql.dll file from /MYSQL/MySQL Server 5.5/lib and paste it to Ruby1.9.2/bin
after that, it is smooth sailing...
Even though I did it, I would appreciate if anyone has an insight into the reason behind this:

On windows there should be a LIB environment variable. Have you checked to make sure that the path to libmysql has been added to this? I suspect it hasn't.

Related

Install Gitlab CE in a GCP instance VM ubuntu 18.04

This is my first time trying to install Gitlab CE in a Google Cloud Platform instanceVM. I have followed two different ways to do that, the official one:
Ubuntu installation
and the one from this tutorial:
How to install gitlab.
However, in both cases I've got the same error:
bash
Running handlers:
There was an error running gitlab-ctl reconfigure:
bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20200523-23121-djcfhu" ----
STDOUT: rake aborted!
TZInfo::DataSourceNotFound: No source of timezone data could be found.
Please refer to https://tzinfo.github.io/datasourcenotfound for help resolving this error.
/opt/gitlab/embedded/service/gitlab-rails/config/application.rb:14:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/Rakefile:5:in `require'
/opt/gitlab/embedded/service/gitlab-rails/Rakefile:5:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
TZInfo::ZoneinfoDirectoryNotFound: None of the paths included in TZInfo::ZoneinfoDataSource.search_path are valid zoneinfo directories.
/opt/gitlab/embedded/service/gitlab-rails/config/application.rb:14:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/Rakefile:5:in `require'
/opt/gitlab/embedded/service/gitlab-rails/Rakefile:5:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
STDERR:
---- End output of "bash" "/tmp/chef-script20200523-23121-djcfhu" ----
Ran "bash" "/tmp/chef-script20200523-23121-djcfhu" returned 1
I have actually followed the link provided by the output Datasource not found but does talk about Ruby on Rails and I'm not using it. So, does anyone knows how to fix this ZoneInfo error in a GCP instance? Or how to let GitLab to ignore it.
Any kind of help will be useful :)
Thanks you all!
Btw, I'm using the bionic's gitlab-ce_13.0.0-ce.0_amd64.deb version
Ok, so i have just noticed that I was using the minimal version of Ubuntu Bionic. With the classical one gets fixed.

sensu server, client and api won't start

I have installed sensu on CentOS-6.5 using the instructions from http://sensuapp.org/docs/latest/guide but i cannot seem to start the sensu-server, sensu-client or even the sensu-api. Any suggestions would be highly appreciated.
Below is the error as logged in the /var/log/sensu/sensu-server.log:
{"timestamp":"2014-10-20T16:58:25.875472+0800","level":"warn","message":"config file does not exist or is not readable","file":"/etc/sensu/config.json"}
{"timestamp":"2014-10-20T16:58:25.875800+0800","level":"warn","message":"ignoring config file","file":"/etc/sensu/config.json"}
{"timestamp":"2014-10-20T16:58:25.875986+0800","level":"warn","message":"loading config files from directory","directory":"/etc/sensu/conf.d"}
{"timestamp":"2014-10-20T16:58:25.876180+0800","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/rabbitmq.json"}
{"timestamp":"2014-10-20T16:58:25.876383+0800","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/redis.json"}
{"timestamp":"2014-10-20T16:58:25.876656+0800","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/redis.json","changes":{"redis":[null {"host":"localhost","port":6379}]}}
{"timestamp":"2014-10-20T16:58:25.876852+0800","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/client.json"}
{"timestamp":"2014-10-20T16:58:25.877063+0800","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/client.json","changes":{"client":[null,{"name":"george-db3","address":"SUBSTITUTE_ME","subscriptions":["all"]}]}}
{"timestamp":"2014-10-20T16:58:25.877277+0800","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/api.json"}
{"timestamp":"2014-10-20T16:58:25.877513+0800","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/api.json","changes":{"api":[null {"host":"localhost","port":4567,"user":"admin","password":"REDACTED"}]}}
{"timestamp":"2014-10-20T16:58:25.897183+0800","level":"warn","message":"loading extension files from directory","directory":"/etc/sensu/extensions"}
{"timestamp":"2014-10-20T16:58:25.897740+0800","level":"warn","message":"loaded extension","type":"mutator","name":"json","description":"returns JSON formatted event data"}
{"timestamp":"2014-10-20T16:58:25.897923+0800","level":"warn","message":"loaded extension","type":"mutator","name":"ruby_hash","description":"returns ruby hash event data"}
{"timestamp":"2014-10-20T16:58:25.898093+0800","level":"warn","message":"loaded extension","type":"mutator","name":"only_check_output","description":"returns check output"}
{"timestamp":"2014-10-20T16:58:25.898257+0800","level":"warn","message":"loaded extension","type":"handler","name":"debug","description":"returns raw event data"}
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:673:in `connect_server': unable to resolve server address (EventMachine::ConnectionError)
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:673:in `bind_connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:649:in `connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/amqp-1.3.0/lib/amqp/session.rb:445:in `connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/amqp-1.3.0/lib/amqp.rb:242:in `connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-transport-1.0.0/lib/sensu/transport/rabbitmq.rb:17:in `connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-transport-1.0.0/lib/sensu/transport.rb:22:in `connect'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-0.14.0/lib/sensu/daemon.rb:133:in `setup_transport'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-0.14.0/lib/sensu/server.rb:726:in `start'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-0.14.0/lib/sensu/server.rb:14:in `block in run'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:187:in `call'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:187:in `run_machine'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-em-2.4.0/lib/eventmachine.rb:187:in `run'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-0.14.0/lib/sensu/server.rb:13:in `run'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-0.14.0/bin/sensu-server:10:in `<top (required)>'
from /opt/sensu/bin/sensu-server:23:in `load'
from /opt/sensu/bin/sensu-server:23:in `<main>'
Typically the message
unable to resolve server address (EventMachine::ConnectionError)
Is a result of a sensu component (server, client, api) not being able to connect to your RabbitMQ server.
Things to check:
Is the RabbitMQ server starting and running?
Check with service rabbitmq-server status
Is the RabbitMQ server resolvable / reachable?
If you're following the sensu docs, I'm assuming your RabbitMQ is local, so this shouldn't be an issue.
Upgrade to the latest version of sensu (currently 0.16.0).
Fixes for crashing on RabbitMQ connection failure were included in 0.13.0 per issue #747.

Cannot install openproject in Windows7 64 bit - undefined method `dlopen' for Fiddle:Module

I cannot install openproject in my system, i have followed all the steps mentioned in the openproject wiki document
I have Windows 7 64 bit and
installed ruby using railsinstaller 2.2.4 from here
mysql mysql-5.6.21-winx64 from here
mysql 32 bit client from here
openproject from git location
Followed document from openproject guide.
i am getting following error,kindly guide to get rid of this issue.
I am very new to Ruby
C:\Users\Administrator\openproject>bundle exec rake db:create:all
require 'rails/all'... 2.309s
Bundler.require... rake aborted!
NoMethodError: undefined method `dlopen' for Fiddle:Module
C:/Users/Administrator/openproject/config/application.rb:68:in `block in <top (required)>'
C:/Users/Administrator/openproject/config/application.rb:44:in `block in bench'
C:/Users/Administrator/openproject/config/application.rb:43:in `bench'
C:/Users/Administrator/openproject/config/application.rb:67:in `<top (required)>'
C:/Users/Administrator/openproject/Rakefile:33:in `require'
C:/Users/Administrator/openproject/Rakefile:33:in `<top (required)>'
(See full trace by running task with --trace)
This does not appear to be a problem with openproject, but rather one with the railsinstaller version you are using. It will go away when you make sure you're using a ruby version above 1.9.3
The openproject installation guide lists ruby 2.1 as a minimal requirement. Unfortunately it seems that there is no railsinstaller that provides a ruby above 1.9, that would render openproject incompatible with railsinstaller on your machine.
Maybe you want to try the railsinstaller-windows 3.0.0-alpha2 with Ruby 2.0.0. Obviously this setup is can not be recommended for production but at least you might be able to get everything running.

What does this error mean as an output from the rails command?

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
from C:/RAILSI~1/INTERE~1/config/application.rb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:53:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.9/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.9/lib/rails/commands.rb:50:in `tap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
C:\RAILSI~1\INTERE~1\config>
This is all the output I could grab because DOS doesn't scroll up.
I am trying to port a rails app from Linux to windows. The only thing different is this app uses mysql. So In installed the MYSQL gem. Both using ruby 191, both using rails 329.
I have done some digging and it seams its because the mysql.dll I put in there is version 5.0 when the mysql gem was compiled for 6.0. Client 6.0 doesn't seem to exist.
I wouldn't normally ask but I am at my wit's end with this.
If you're using version 2.9.x of the MySQL gem, it was built against MySQL 6.0 and you can download the correct version of the C Connector from the MySQL web site. After installing the mysql gem, it should have given you a URL to go to to download the correct version. However, if you installed mysql using bundle install then the post-install message may not have been displayed.
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/http://cdn.mysql.com/
There's the URL to grab the binary library as a ZIP file.
http://dev.mysql.com/downloads/connector/c/
In case the first link doesn't work, there's the URL with all of the available C Connector downloads. You want Windows (x86, 32-bit), ZIP Archive (the second one; the one where the filename does not end in vs2005).
If the MySQL library still comes up as a mismatch, do a gem list mysql to get the version that is installed, then uninstall and reinstall the gem manually:
gem uninstall mysql
gem install -v=x.x.x mysql
Replace x.x.x with the version number that was reported previously. After the gem is installed, it should give you the URL of the C Connector you need to install.

Standalone script reports "MySQL server has gone away"; problem with my.cnf?

I have a ruby script that requires 'mysql2' and uses query statements to mysql like
#db.query("SELECT sname,id FROM streets where region_id=#{region["id"]}")
but it reports me a error always like this:
main.rb:261:in `query': MySQL server has gone away (Mysql2::Error)
from main.rb:261:in `block (3 levels) in <main>'
from main.rb:258:in `each'
from main.rb:258:in `block (2 levels) in <main>'
from main.rb:254:in `each'
from main.rb:254:in `block in <main>'
from main.rb:253:in `loop'
from main.rb:253:in `<main>'
The script on my Ubuntu is OK, however, my production environment is CentOS and on there I installed MySQL from source code. My Rails app run there is OK and it also requires 'mysql2', but when I run this script it fails.
I think the problem is related to my.cnf but I don't know how configure it.
The mysql2 gem provides an option to reconnect to MySQL in the event that the connection goes away. Rather than updating your my.cnf file, update your gem's database.yml file to include the
reconnect: true
option. This will ensure that the mysql2 gem will attempt to reconnect to MySQL when required.
you call .query method directly on object #db... what exactly is this object?
I mean... if you are under Rails, you should call queries like:
result = ActiveRecord::Base.connection.execute("sql here")
I think it could be the cause, because Rails manages connection pool (eg. 5 established connections and every query goes to one of them, based on requests).
Anyway, if this is not the cause, then it can be that your mysql2 gem is compiled with different version of libmysqlclient.so library on the system...
Then when you try to do a query, it internally throws an error about incompatible protocol and disconnects...
Please check that your libmysqlclient.so and it's header files are of the same version...
Or if you don't have more versions of them installed...
and then please try to recompile mysql2 gem.
Hope this helps.
Regards, NoICE