Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Friday, May 27, 2011

Thinking Sphinx giving error "Failed to start searchd daemon"

I have Rails 3.0 application running on Windows 7. I am using Thinking Sphinx. I configured it and worked for few days. One day, after some file update when I ran "rake ts:start", it gives following errors:

C:\projects\demo>rake ts:start
(in C:/projects/demo)

Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name

For more information, read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html
C:/Ruby187/bin/rake: No such file or directory - searchd --pidfile --config "C:/projects/demo/config/development.sphinx.conf"
Failed to start searchd daemon. Check C:/projects/demo/log/searchd.log.
Failed to start searchd daemon. Check C:/projects/demo/log/searchd.log

When I checked 'searchd.log' file it displays following error:
[Wed Apr 27 19:28:50.187 2011] [  236] accepting connections
[Wed Apr 27 19:35:05.546 2011] [  236] caught SIGTERM, shutting down
[Wed Apr 27 19:35:05.630 2011] [  236] shutdown complete

Steps to fix the error:

Change the 'config/sphinx.yml' file and give path to bin directory where Sphinx is installed as given below:
development:
  bin_path: "C:/Sphinx/bin"

Then run
rake thinking_sphinx:index
rake thinking_sphinx:start
and it will run without any error.

Thursday, March 31, 2011

Steps to install pik, add ruby to pik list and switch between Ruby version

I use Pik to manage multiple versions of ruby on a Windows machine. Here are the steps to install pik:

Install the pik gem
> gem install pik
......
Successfully installed pik-0.2.8
1 gem installed

Then check path
>path
PATH=C:\Program Files\ImageMagick-6.6.4-Q16;C:\Program Files\ImageMagick-6.5.6-Q8;C:\Windows\system32;C:\Program Files\Git\bin;C:\Program Files\Git\cmd; C:\Ruby187\bin

Then Install pik to a location other than your ruby\bin dir. I used C:\pik

>pik_install C:\pik
Thank you for using pik.
Installing to C:\pik
...
pik is installed

It will install pik and will create a folder 'pik' in C:\ drive. You will get 'C:\pik'
Now add the variable 'C:\pik' in your 'Environmental Variables' path.

For steps to add path in 'Environmental Variables' or troubleshooting the setup of 'Environmental Variables', please see post "setting-path-cpik-in-environmental-variable"

Download Ruby 1.9.2 exe from http://rubyforge.org/frs/download.php/74298/rubyinstaller-1.9.2-p180.exe
Install and add the new Ruby version to pik registry.

>pik add C:\Ruby192\bin

You can check the List of all available Ruby versions added in pik, one with the '*' sign displays the default one:

>pik list
* 187: ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
   192: ruby 1.9.2p180 (2011-02-18) [i386-mingw32]


>ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]


To switch to Ruby 1.9.2:

>pik 192
>pik list
   187: ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
* 192: ruby 1.9.2p180 (2011-02-18) [i386-mingw32]



>ruby -v
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

To switch back to Ruby 1.8.7:
>pik 187

Its over and pik is successfully installed, now you know how to install pik, add ruby to pik list and switch between Ruby version

Installing mysql2 gem on Ruby 1.9.2 and Rails 3.0.5 on Windows


When running 'bundle install' or 'gem install mysql2', I got following error:
>gem install mysql2
ERROR:  Error installing mysql2:
        The 'mysql2' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
 To solve this issue and to successfully install mysql2 gem, I took following steps:

1. Download Development Kit "http://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe" from http://rubyinstaller.org/downloads/
2. Followed the instructions given on link https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
3. Extracted the downloaded DevKit.
4. cd <DEVKIT_INSTALL_DIR>
5. run ruby dk.rb init.

C:\Users\ritesh\Downloads\DevKit-tdm-32-4.5.1-20101214-1400-sfx>ruby dk.rb init
[INFO] found RubyInstaller v1.9.2 at C:/Ruby192
[INFO] found RubyInstaller v1.8.7 at C:/Ruby187

Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

6. edit the generated config.yml file as per your system available Rubies version if required
7. [optional] ruby dk.rb review to verify the changes you made to it are correct.

8. finally, ruby dk.rb install to DevKit enhance your installed Rubies.


C:\Users\ritesh\Downloads\DevKit-tdm-32-4.5.1-20101214-1400-sfx>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby192'
[INFO] Installing 'C:/Ruby192/lib/ruby/site_ruby/devkit.rb'
[INFO] Skipping existing gem override for 'C:/Ruby187'
[WARN] Skipping existing DevKit helper library for 'C:/Ruby187'

9. You have successfully installed the DevKit, and now comes the step to install mysql2 gem, most important one for which we took so many steps. Make sure you are using Ruby 1.9.2 version.

10. Run gem install myql2 with parameters that I have passed, path can differ for you so make changes accordingly.

>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"'
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.2.7
1 gem installed
Installing ri documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known

And, congrats, you are done with installation of Mysql2 gem on Ruby 1.9.2 and Rails 3.0.5 on Windows.