How to get NetBeans 7.4, Ruby and MySQL to play together (on Windows) - mysql

The tags say it all, really. This is a project that used to work on earlier versions, but not now. If you know the answer, just stop reading and tell me how.
An existing project is working fine on older releases of NetBeans and MySQL. I am just trying to get it working on the latest release of everything. Nothing fancy. Just plain vanilla Ruby on Rails on Windows/MySQL.
Clean install of Netbeans 7.4. No problems.
Clean full install of MySQL 5.5. No problems. Includes Java connector.
Clean install of ruby and rails from community: http://plugins.netbeans.org/plugin/38549. No problems.
Everything is working just fine.
Webrick starts and runs. Absolutely no surprises to this point.
I tried to gem install MySQL: it fails, but it is not unexpected. I have no interest in pursuing that line. Ditto for MySQL 2. It's always hard building native libraries on Windows.
I tried to gem install all/any of the following:
* activerecord-jdbc-adapter
* activerecord-jdbcmysql-adapter
* jdbc-mysql
They install just fine, but the end point is always the same:
cannot load com.mysql.jdbc.Driver.
I think I know what this means, but I have no idea how to fix it. Is it a classpath problem? Is it a bug? Is it an incompatibility just about to be fixed? Is it because I'm using Windows? Who knows? I can't think of anything else to try, and the forums are full of these errors with no solutions that seem to fit my problem.

I am not sure, but maybe the blog post Installing MySQL on Windows 7 x64 and using Ruby with it will help.

Related

Trouble Setting Up Ruby On Rails

I'm attempting to start learning Ruby on Rails via a YouTube tutorial series(https://www.youtube.com/watch?v=GY7Ps8fqGdc), but seem to be struggling getting everything properly installed and set up to do so. The tutorial requires MySQL with MySQL Workbench and Ruby on Rails. I've gotten several errors in the first few steps and taken some steps to try to resolve them, here's basically where I've gotten.
Installed the most recent version of MySQL and Ruby on Rails. I ran the rails new [name] -d mysql command without issue and it ran to completion. I then navigated to the newly created project folder and ran the bundle install at which point I was given the following error:
Gem::InstallError: nio4r requires Ruby version >= 2.3.
An error occurred while installing nio4r (2.5.2), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.5.2'` succeeds before bundling.
At this point I installed version 2.6 of Ruby on the machine, which did not seem to yield any improvements. Basically I think I'm overcomplicating all of this and want to know if anyone has an easy solution to install all the tools required for working in Ruby on Rails.
Thanks
First thing first, you're following a 5 yr old tutorial on youtube.
I would advise to always follow the newer ones even though some of the old ones might still work and the reason is simple; recent tutorials will probably work off the bat.
Now, judging by the video you shared, I can see that you should've installed RVM at some point. Official RVM website
In your terminal run ruby -v and check if you're actually using the Ruby version you just downloaded. To change the ruby version while using rvm you should use in your terminal:
$ rvm list
To check on your available ruby versions installed and then
$ rvm use <version>
This will switch your ruby version to the one you want. ( If you already installed it of course. ) and then try bundle install again.
Since you were asking for an easier solution I'd say to try following Rails official getting started guide. This guide installs the minimum amount of gems which will help you avoid all these version issues and even though it uses sqlite instead of mysql, later on you will be able to switch to mysql if you want with a better understanding of it.

Can't get JRuby to work on AIX machine

I looked everywhere and I can't find any help on how to get JRuby to work on AIX. I tried unpacking the binary package, tried using the jruby-complete.jar but I stumble on the same problems.
All errors seem to occur because JRuby is looking in the wrong directories for lib files.
For instance, I set my GEM_PATH=/home/dev999/install_tmp/gem and then I try to require activerecord-jdbc-adapter, which is installed under ./gem/gems/activerecord-jdbc-adapter-1.3.12, but for some reason JRuby keeps looking for the gem under ./gem/gems/activemodel-4.1.8/lib as shown below.
dev-host:/home/dev999/install_tmp$ jruby -e "require 'activerecord-jdbc-adapter'"
Errno::ENOENT: ENOENT - /home/dev999/install_tmp/gem/gems/activemodel-4.1.8/lib/activerecord-jdbc-adapter
file? at org/jruby/RubyFileTest.java:131
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:46
any? at org/jruby/RubyEnumerable.java:1473
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:46
any? at org/jruby/RubyEnumerable.java:1473
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:44
find_inactive_by_path at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/specification.rb:898
find at org/jruby/RubyEnumerable.java:592
find_inactive_by_path at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/specification.rb:897
try_activate at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems.rb:183
require at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:132
(root) at -e:1
Any insights on what may be causing this are greatly appreciated.
EDIT: The server is an AIX 64 bits; we tried Java 1.6 and 1.7 both 64 and 32 bits (IBM custom build for AIX) but we ended up sticking with 1.7 64 bits in the final solution, although the version doesn't seem to affect the issues found in the Ruby 1.7.9 installation, but since we couldn't get JRuby 1.7.16 to work, I can't be sure if the Java builds we used could have played part in the problem.
OK, so the server admin and I spent two days trying to figure these things out and I can finally summarize the solution we ended up with to get JRuby working on AIX_64.
1 . First and most important of all, I had to install JRuby 1.7.9 since the 1.7.16 stable version from the main download page in jruby.org has many (seemingly AIX specific) bugs that we could not figure out; for instance, the wrong gem path resolution shown in my original question. Version 1.7.9 sorts out most of the issues automatically;
2) For some weird reason that I'm still unable to figure out, jirb won't work with the jline-2.11.jar lib that comes with the downloaded JRuby package. At some point I got it to work but then I could not retrace my steps so I gave up. To sort this issue out I downloaded jline-1.0.jar and replaced the jline jar located under <jruby_path>/lib/ruby/shared/readline/jline-2.11.jar; please note that even if we are replacing this with jline-1.0, the jar file name must still be the same i.e. jline-2.11.jar otherwise jirb will complain about a missing lib;
3) Some common steps: add jruby/bin to $PATH; make sure which java shows the correct Java version you want to use; set $JAVA_HOME;
4) (Optional, but very useful) in order to avoid having to grant my user write access to the /usr/<jruby>/<gem_paths> directories but still allow me to install gems without having to ask the admin I added export GEM_PATH=~/.gem to my .profile, then mkdir ~/.gem. To install gems to my home directory I do jgem install <gem_name> -i $GEM_PATH.
Hopefully this helps other users struggling with the same problems.
My main suggestion is to join the jruby mailing list and ask there. I've used jruby just once and managed to get it working. Here is a bit of magic that I don't really understand that I have at the top of one of the first files I require:
# We need the db2j.jar loaded
require 'db2j.jar'
# Some feaking magic Java needs
Java::JavaClass.for_name 'com.ibm.db2j.jdbc.DB2jDriver'
# The connection string is jdbc:db2j:the/path/to/the/file where the
# file is actually a directory.
CloudscapeDriver = 'jdbc:db2j'
You can see the email thread here: http://comments.gmane.org/gmane.comp.lang.jruby.user/17856
good luck

MySQL Ruby Gem installation error

I can't install the MySQL gem. I know this is a very common error but I have searched and tried everything I could. I have been trying to fix it for more than a week and I am very frustrated. I am working on Windows 7 64-bit machine.
I have tried this: http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
And moving the libmysql.dll to the bin folder of the ruby installation and still no success.
I also tried 64 bit and 32 bit versions.
I would love to get this problem out of the way to actually start learning...
I will answer as fast as possible to provide any information you need.
Thank you very much, whoever solves it will be my hero!
EDIT: Here is the error I am getting. It is very common.
http://imgur.com/wx9rEJX
EDIT: FIXED
I ended up using:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector"'
And this time it worked! I hope this can help anyone with this problem.
Source

Ruby on rails undefined method `where' for #<Class:0x10377d590>

I am trying to migrate from windows 7 to mac osx .
I have installed the following
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
mysql Ver 14.14 Distrib 5.1.56, for apple-darwin10.3.0 (i386) using
readline 5.1
After a lot of pain I installed my sql gem by :
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
But still when I run my project in netbeans I get the following error
[4;36;1mUser Columns (31.5ms)[0m
[0;1mSHOW FIELDS FROM users[0m
[4;35;1mSQL (1.2ms)[0m [0mSHOW
TABLES[0m /!\ FAILSAFE /!\ Wed May
04 09:53:16 +0530 2011 Status: 500
Internal Server Error undefined
method `where' for
Can anyone tell me what am I doing wrong ?
The database migrations are working perfectly.
You stopped copying the stack trace right at the point where it was about to tell you where the error occurs. Look down the stack trace for the first mention of any code from your app (as opposed to the gems or the vendor folder) and it should point you to the problem line.
It's unfortunate that you've having such a time installing the MySQL gem, but this can be complicated if you're loading it on a from-scratch machine that's missing the development headers, something required to compile the extension, and your path does not include /usr/local/mysql/bin which is common.
You can fix that by creating a file /etc/paths.d/mysql with the following:
/usr/local/mysql/bin
Generally you should just have to list mysql in your Gemfile after that, and it should install conventionally with bundle install.
As for the error, it looks like something deeper in your application that's blowing a gasket. When you say "run your project in netbeans," but do you mean run unit tests? It looks like you're calling where on something that doesn't support it.
This looks like an application error. The server is bailing with a 500 when it fails to evaluate the method 'where', somewhere likely in your code.
Modern Mac operating systems (forget which was the first) come with ruby and rails pre-installed - not sure if this is related to your setup.
What happens when you run
rails server
from the console (from within the directory of the app) ?
where is a ActiveRecord 3 AREL class method used for conditions.
First things first, do you have XCode installed? thats a prerequisite to installing any native gems. You can download XCode 3 from the apple site or buy XCode 4 from the app store.
More of the stack trace is required.
Ideally though, once you have installed XCode, you should take a look at https://rvm.io - it's the preferred way for managing rubies on Unixy systems.
Thanks guys.. I finally found the error was with the authlogic gem
I had installed 3.0.2
and the application requires an older version 2.x

How Do I Correct mysql.rb Drivers?

For the last several days, I've been struggling to get ruby on rails to work on my mac. The main culprit is MySQL. Every time I fix one thing, another error shows up. I upgraded/downgraded MySQL to play nice with ruby, rail and gems, but nothing. My latest error is:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
/!\ FAILSAFE /!\ Wed Aug 05 21:09:23 -0700 2009
Status: 500 Internal Server Error
dlopen(/usr/local/lib/ruby/site_ruby/1.8/i686-darwin9.7.0/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib...
I don't have libmysqlclient.16.dylib; just *.15.dylib. Tried all the techniques, even installed or tried to install ruby-mysql-0.2.6 posted at tmtm.org
FYI: Last error prior to the one stated above had to do with authentication.
Appreciate any help.
Well, this question is a bit old already, but since I got here after getting the same error (but on LINUX), I would like to post my solution for future reference.
I simply had to install ruby-mysql.i686
yum install ruby-mysql.i686
Hope it helps somebody else in the future... tnx
Have you installed Xcode Developer tools? You can download it for free at http://developer.apple.com/.
Whenever I have issues with Ruby and MySQL, I never had Xcode installed. Could be wrong.
Answering my own question.
I don't know why and I don't know how, but took #Garrett's advice and re-installed Xcode. That didn't do anything. Went ahead and upgraded MySQL after that, which I had done before, and voilá! it worked. I'm guessing both re-installations finally got it working somehow. Weird!
Try using the below command . Provide the location of the mysql directory in your Mac .
sudo gem install mysql -- --with-mysql-dir= /usr/local/mysql
It looks like you haven't specified the location of mysql directory .
Good luck !