|
|
My Windows machine had ruby 1.9.2 and Rails 3.1. Now that ruby 1.9.3 and rails 3.2 are out, it was time to upgrade. This method isn’t the easiest, but it worked just fine for me. Note that this machine has MySQL version 5, so step 7 is necessary for me. If you have MySQL version 6, copy libmysql.dll from there if it isn’t already on the path.
1. Install the latest version of ruby (currently 1.9.3-p125)
a. Follow the instructions on rubyinstaller.org
b. I recommend you use the defaults (install to C:\ruby193)
c. make sure to also install DevKit (install to C:\ruby193\DevKit)
2. install pik
a. gem install pik
b. pik_install C:\bin (or other directory that is always on your path)
3. Add this ruby to pik
a. pik add C:\ruby193\bin
4. Use this version of ruby
a. pik use ruby 1.9.3p125 (note: there is no dash between the version and the p)
I put this in a batch file, rather than have it load automatically with cmd
5. gem install rails
6. gem install mysql2
7. copy version 6 of libmysql.dll to C:\ruby193\bin (same directory as this version of ruby.exe)
a. download it from the site shown on the gem install mysql2
8. rails new yourproject -d mysql
9. cd yourproject
10. edit database.yaml so adapter is mysql2
11. bundle install
Upgrading to ruby-1.9.2-p290 on my development machines (Windows and Linux) was a breeze. There were some extra steps needed to upgrade on the server:
1. rvm get head
2. rvm reload
After that, just:
3. rvm install ruby-1.9.2-p290
4. rvm –default 1.9.2-p290
5. rvm gemset create 3.1.1
6. rvm gemset use 3.1.1 –default
7. gem install rails –no-rdoc –no-ri
and ready to roll.
I just upgraded my Windows XP computer to use Ruby on Rails 3.1.1 with MySQL 5.1. Here’s how I did it:
0. pik is already installed via gem
1. Download rubyinstaller-1.9.2-p290.exe
2. Install ruby at c:\ruby\1.9.2-p290
3. pik add c:\ruby\1.9.2-p290\bin
4. Download DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe
5. Install DevKit at c:\ruby\1.9.2-p290\DevKit
6. PATH=C:\ruby\1.9.2-p290\DevKit;%PATH%
7. pik use ruby 1.9.2p290
8. gem install json –platform=ruby
9. gem install mysql2 — ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.1\lib\opt” –with-mysql-include=”c:\Program Files\MySQL\MySQL Server 5.1\include”‘
and now create a new rails app as usual:
rails new -d mysql
bundle install
and everything works!
My first non-trivial Rails 3.1.0 app is working less than one hour after installing the rails 3.1.0 gem. Here is what I needed to do, including the rails install:
1. rvm gemset create 3.1.0
2. rvm gemset use 3.1.0
3. gem install rails
4. cd
4. rails new
5. cd rails_app
6. edit config/database.yml (user, password and database)
7. edit config/application.rb (added one directory to path)
8. edit Gemfile (added two gems ‘execjs’ and ‘therubyracer’)
9. bundle install
10. copied over two models, one helper and one app file under /lib
11. changed program debug variable to 0
12. ran the app
Note: So far, this app has no views. It does have multiple models and a 49 year-old database that started as flat files..
Using Ruby 1.9.2, Rails 3.0.9, and rake 0.9.2
This happened to me when doing a heroku rake db:migrate. The solution:
In my Rakefile, add require ‘rake/dsl_definition’ before require ‘rake’
Hat tip to http://stackoverflow.com/questions/6181312/how-to-fix-the-uninitialized-constant-rakedsl-problem-on-heroku and Kale!
I recently received this message while running my first cucumber application on my XP development machine:
ruby.exe – Unable To Locate Component
This application has failed to start because msvcrt-ruby18.dll was not found. Re-installing the application may fix the problem.
The solution turns out to be easy. Update old gems that still use ruby 1.8. In my case:
1. gem update –system
2. gem uninstall json
3. gem install json
In my case, this updated rubygems to 1.6.2, and json from 1.4.6 to 1.5.1.
Installing ruby 1.9.2 on Windows took several false starts before I got on the right track.
My development machine is a dual-boot Windows and Linux monster with pre-existing versions of Ruby, Rubygems, Rails, and MySQL. On the Windows side, I have a working version using ruby 1.86, rubygems 1.3.5, rails 2.3.8, and MySQL 5.1. The oldest version of ruby was sitting in C:\ruby\bin, with newer versions in subdirectories like C:\ruby\1.9.2-rc2. I get some warning messages because the ruby version is older than the rubygems and rails, but the bottom line is the programs work. So, writing over a working version of ruby or MySQL was not an option.
The rvm gem is not available on Windows, so to switch ruby versions I run a batch script that prepends the desired ruby bin to the path. I tried to install ruby version 1.9.2-p0 in the same way that I had 1.8.7, but got flaky errors. For whatever reason, the 1.9.2 ruby version had the 1.8 gems on the path. This meant that I could install gems on 1.9.2, and gem list would report the new gems, but programs used gems from 1.8. This was not good. I finally installed ruby 1.9.2 in a directory that was not a subdirectory of C:\ruby, made sure the path had only one ruby entry, etc. Finally I chose to regedit and revise any references to ruby 1.8 executables to ruby 1.9.2. Now ruby 1.9.2 programs were using the gems I had installed. But programs using MySQL still didn’t run.
One error I frequently (but not always) saw was segmentation fault. Luis Lavena says that is always a MySQL dll issue. He was right. Luis Lavena is the expert on ruby and Windows. He said that you need to run MySQL 5.0, as the ruby bindings use that version of libmysql.dll. Plus, the documentation on the web references the mysql gem but not the mysql2 gem. Luis Lavena is correct, but incomplete.
First, the mysql2 gem now works on Windows with ruby 1.9.2, and the rails s command expects the mysql2 gem if you specified -d mysql when creating your rails project. The solution was to have the libmysql.dll from MySQL 5.0.89 as the first/only libmysql.dll in the path. But you don’t need to install an old version of MySQL to do this. The best solution is on http://www.fuyun.org/2010/01/ruby-mysql-adapter-on-windows/. Download mysql-noinstall-5.0.89-win32.zip, which can currently be found at http://dev.mysql.com/downloads/mysql/5.4.html, and extract only libmysql.dll from there, using your favorite unzip program (mine is 7-Zip). Then, place libmysql.dll in your path. I have it in my ruby bin; your path may differ.
To complete the solution, I’ve taken both my ruby bin and MySQL Server 5.1\bin off my default path and added two batch files to add one or the other back in. There is a ruby gem patheditor that you may want to try out, but of course it requires that ruby be in your path.
Addendum: April 6, 2011 With the latest versions of Rails (3.0.5) and the mysql2 gem (0.2.6 and 0.2.7), you need to use the MySQL 5.1 version of libmysql.dll instead of the MySQL 5.0.89 version. Either have the MySQL 5.1 bin in your path or a copy of the MySQL 5.1 version of libmysql.dll somewhere in your path.
I needed to serve both static and Ruby on Rails (RoR) pages on my rubyat.com site running Debian gnu/Linux stable (lenny). The apt-get/Debian way is unsatisfactory, as, among other issues, Debian does not yet have Passenger in its stable (lenny) branch. After doing some research, and some trial and error, this is what worked for me.
1. Uninstall any gems. I’d installed rake and Rails via Debian apt-get. Unfortunately, most Ruby gems aren’t available that way.
2. Uninstall rubygems via apt-get. Same logic.
3. Install ruby development headers.
sudo apt-get install ruby1.8-dev
4. Install rubygems from source. This gets me the newest version of rubygems, and also makes all future gems available.
sudo wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
sudo tar -xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb
5. Install Rails.
sudo gem install rails (Installs the latest stable version of Rails. Today it is 2.3.8).
6. Install Passenger.
6a. Install the Passenger Ruby Gem.
sudo gem install passenger
6b. Install the Apache Passenger module.
sudo apt-get install apache2-prefork-dev
sudo apt-get install libapr1-dev (Note: already installed on my machine.)
sudo apt-get install libaprutil1-dev (Note: already installed on my machine.)
sudo passenger-install-apache2-module
6c. Edit my Apache configuration file. In Debian, this is /etc/apache2/apache2.conf.
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby1.8
Now, some of my web sites use an older version of rails. So:
7. Install older version of rails.
sudo gem install -v=2.1.0 rails
8. Restart Apache.
sudo /etc/init.d/apache2 restart
At this point, Ruby on Rails pages get served, but other content (such as this WordPress blog) does not.
9a. Edit my site Apache configuration.
sudo nano /etc/apache2/sites-available/mysite
inside <VirtualHost> add the following three lines:
<Location /blog>
PassengerEnabled off
</Location>
And these three lines:
<Location /mail>
PassengerEnabled off
</Location>
9b. Restart Apache.
sudo /etc/init.d/apache2 restart
9c. Test the configuration. Make sure everything works. For me, it does.
I just upgraded to Rails 2.3.8 on my development machine. I created a standard Rails app, started up WEBrick, and got a Segmentation fault. Not enough code to be my error, so I searched for the core problem and possible solutions.
Turns out the issue is known, and a solution exists. First, I updated to the latest version of Ruby 1.8.6. Not 1.8.7, and certainly not 1.9.2. Too many people reported unresolved problems with Ruby 1.8.7, and Ruby 1.9.2 hasn’t yet gone stable. As of 16 June 2010, the latest version available as an exe for Windows is ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32].
Next, did a gem install rails (version 2.3.8). Third, a gem install mysql (2.8.1 x86-mingw32). This gave errors for the documentation, but the gem installs.
Finally, I copied libmySQL.dll (1484 KB) from http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll as recommended at http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407 . After that, everything just works.
Installed Rails 3.0.0.beta on my test machine. Here’s a few notes on what was easy, what was not.
My test machine uses Debian squeeze (testing), ruby 1.9.1 and rubygems 1.3.5. You need to have ruby 1.8.7 or newer. Ruby 1.8.6 will not work.
To find out what version of ruby you have, enter: ruby -v.
For a full rubygems environment listing, enter: gem env
To find out what paths ruby is looking for, enter: irb
followed by: puts $LOAD_PATH
My first attempt in installing Rails 3 failed, with this error message:
sudo gem install rails –pre
ERROR: Error installing rails:
actionpack requires rack-mount (~> 0.4.0, runtime)
So, I get to go a bit deeper:
sudo gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
sudo gem install rack-mount –version 0.4.0
sudo gem install rails –pre
But this isn’t enough to create a new project. So:
sudo gem install abstract
rails rubyat.com -d mysql
Now, there’s still more to be done in order to use rails console:
sudo apt-get install libmysql-ruby1.9
sudo apt-get install libmysqlclient-dev
sudo gem install mysql — –with-mysql-dir=/usr/bin –with-mysql-lib=/usr/lib/mysql
sudo gem install mime-types
sudo gem install text-hyphen
Finally, enter: rails console and we have the familiar irb console.
|
|