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
Related
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.
I cannot seem to run a rail application configured to MySQL. When I run the project, I get the following error:
193: %1 is not a valid Win32 application. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
I've noticed others have hit this but I didn't find any solutions that worked for me. Here's what I've tried so far:
Copying libmysql.dll to the ruby bin folder
Tried older version of MySQL (5.0)
Checked the ImagePath for MySQL on regedit
Can anyone provide guidance here? Is this just a lost cause? Does using Linux or other versions of Ruby/Rails/MySQL combo fix this?
Looks that you installed the binary pre-compiled version of MySQL gem, which requires an specific version of MySQL to be installed.
More important, it requires an specific version of libmysql.dll be available in the PATH so the gem can use it.
I would recommend you uninstall the pre-compiled gem and proceed with the manual compilation steps described here:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
This has been answered before too:
Ruby Gem for mysql 5.5 in windows
Is Datamapper's dm_mysql_adapter gem supported on windows?
Finally installed MySQL for Rails in Windows 64 bit, and now
on windows Mysql native extension prob in ruby on rails gem time
Hope that helps.
I feel I've gone through every post on this subject, and I'm still banging my head against the wall.
I am running...
Mac OS 10.6.6
MySQL 5.1.4.4 (on MAMP) or (MySQL 5.5.8 in my /usr/ directory) both can be running and work fine
Ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.6.0] (using RVM)
Rails 2.2.2
Gem 1.4.2
MySQL gem 2.8.1 (it says it's installed)
When I fire up the RoR app I've been developing, the mongrel appears to load fine. When I try to bring up the app in my browser I get the following error...
/!\ FAILSAFE /!\ Thu Jan 20 19:46:07 -0500 2011
Status: 500 Internal Server Error
uninitialized constant MysqlCompat::MysqlRes
then what follows are a bunch of lines like...
/Users/PJ/.rvm/gems/ruby-1.8.7-p330/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:442:in `load_missing_constant'
I feel I have tired every variation of the ARCHFLAGS solutions that have been previously suggested on other posts. None have worked.
I am using MAMP and RVM as I have done other uninstalls and re-installs of MySQL, Ruby, Rails and various gems in attempts from other suggested solutions.
The app worked fine prior to my update to Snow Leopard. I am not a very sophisticated developer type, so I apologize in advance for being, well, not the brightest.
Try this AFTER making sure that Xcode is installed on your system.
gem uninstall mysql
export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --
no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/
local/mysql/bin/mysql_config
I coudn't ever seem to get the 2.8.1 mysql gem to work.
I downgraded it to the 2.7 version which led to a series of new errors (a DYLD_LIBRARY_PATH error), but it was eventually figured out and I am up and running again.
I've been struggling with this for a few hours. Everything just stopped working and I can't get it to work anymore. I'm a noob at Ruby, Ruby on Rails and the Terminal in general. This is really frustrating me so I just try to describe my problem as detailed as possible hoping someone can give me a solution.
I'm on Mac OS X Snow Leopard. I couldn't get Rails working at all just now: Could not find gem 'rails' headaches
But after some tries of reinstalling it, it suddenly worked again. But now I just can't get MySQL to work, and it sometimes even breaks the Rails installation again.
This is what I do:
sudo gem uninstall rails
sudo gem uninstall mysql
sudo gem uninstall mysql2
After these commands, I check the installed gems with gem list. No MySQL gem is listed anymore, but I can still see rails (2.3.5, 2.2.2, 1.2.6)
. Is this normal? Does this mean I have 3 Rails installations? It doesn't make sense to me. Anyway, then I do this:
sudo gem clean
Which fails completely. I get a bunch of errors like this:
Attempting to uninstall fcgi-0.8.7
Unable to uninstall fcgi-0.8.7:
Gem::InstallError: cannot uninstall, check gem list -d fcgi
It doesn't uninstall anything. At this point, I try to install everything again. I start with:
sudo gem install rails
Which succeeds (I think):
Successfully installed rails-3.0.3
Successfully installed builder-2.1.2
2 gems installed
Installing ri documentation for rails-3.0.3...
File not found: lib
Then, I update RubyGems:
sudo gem update --system
sudo gem install rubygems-update
sudo update_rubygems
Then it says I have 1.3.7 installed, so it succeeded, I think. So now I proceed with installing MySQL. I already got MySQL 5.5.8 installed on my machine. I did some research about installing MySQL on Snow Leopard, and it seems I have to use this command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I get a bunch of errors like this:
No definition for time_set_neg
No definition for time_set_second_part
No definition for time_equal
No definition for error_errno
At this point, I assume I got both Rails and the MySQL gem installed, so I try to start a new project.
rails new user_group -d mysql
It works! Rails is installed correctly. Now, I try generating a model.
cd user_group
rails generate model User
It fails with this error:
Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources listed in your Gemfile.
Try running bundle install.
So I try running bundle install. It installs a lot of gems. Then I try to generate my model again. I get this error:
Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
This is as far as I can get. What should I do? And why should this be so hard...
Snow Leopard supplies Ruby 1.8.7. Ruby 1.8.7 doesn't automatically add the require 'rubygems' command to a Ruby script, like 1.9.2 will, so in general you need to add that to your script. That fixes the problems with Ruby not finding the gems called by your code in a lot of cases. Rails is a different animal, but the version with 1.8.7 is well documented so you should have found a fix pretty quickly.
The Ruby supplied by Snow Leopard is really for its own use. Users can piggyback on that, but it's installed by Apple because they have applications that use it. Use locate podcast | grep rb$ to see. Similarly, Perl and Python in Snow Leopard are used to support code Apple has installed so messing with them is not a good idea. Changing the built-in Ruby, Perl or Python usually won't cause the system to explode in flames, but it can cause irritating and unexplained problems farther down the road when system maintenance routines stop working.
By using sudo to remove gems installed by Apple and add new ones, you've left your system Ruby in an unexpected state as far as Apple's apps are concerned. Rather than mess with Apple's Ruby, you should install a separate Ruby for your own use using Fink or MacPorts, or from source code, or by using RVM.
Personally, I use RVM because it creates a ~/.rvm sandbox in your home directory, and makes it easy to manage multiple versions of Ruby and gems. RVM requires you to install the XCode development library, which you can download from http://developer.apple.com/technologies/ after a free registration. XCode is also on your system DVD, but that version is reported to be buggy, so use the downloaded version.
Make sure to add the MySql gem to that projects gemfile with the following code:
gem 'mysql', '2.8.1'
Run a bundle install/update and try it. You told it to use MySQL and the gem might even be installed, but you aren't loading it.
Also, you're failing at a couple of points: notice the
File not found: lib
Then again, I could be completely wrong about this - it's my attempt at providing a clue for your troubleshooting.
ah...it is not easy to get started ruby on rails to me..
I am trying to use mysql for ruby on rails development.
When I execute "gem install mysql", I get following error.
error: while generating documentation for mysql-2.8.3-x86-mswin32...message: unhandled special: special: type=17...bla bla...
how do I install mysql for ruby on rails!??!
If you are on windows and want to avoid mysql issues, just use v 2.1.2, just before they removed the mysql connector and put it into the mysql gem. It's better like that, but I ran into MANY issues installing this on the Windows XP machine at my work.
Make sure that your version of gems is the latest.
You should be able to update it using:
gem update --system
Going by your error it failed to generate the documentation for the Gem, though it could have installed it as it was. Firstly check to see if it did install, use:
gem list --local
And check to see if the MySQL driver is in the list already.
If it isn't the make sure you're installing the correct version of the driver, either mswin32, or ruby should do.
That's an error concerning rdoc generation. If you execute the following command you'll get no error:
gem install --no-rdoc mysql
I believe there are some problems generating rdoc for the Japanese localized version of the docs. Anyway, the mysql gem gets installed.
You can easily install the MySQL gem
either install the MySQL in ruby file where all gems are install or you can follow the path:
C:\Ruby192\lib\ruby\gems\1.9.1\gems
execute the below command:
gem install MySQL
hope this helps you!