How to Install ROR and Spree 2.0.x on Windows

Spree is a e-commerce development platform built in Ruby On Rails .

In this post , we will install and run a sample web application built in spree. First of all , install Ruby version > 1.9.x .

Step 1
you have to install devkit also .

After that, install rails , using following command:

$ gem install rails -v 3.2.13

Step 2
Install imagemagick, it is used by spree.
Make sure your rails version is not 4.0 , otherwise you may get “. is not a rails project ” error.
Now install spree and create a rails project by these commands:

$ gem install spree
$ rails _3.2.13_ new my_store

If you get following error:

C:\Users>spree install my_store
Would you like to install the default gateways? (Recommended) (yes/no) [yes] yes
Would you like to install the default authentication system? (yes/no) [yes] yes
Would you like to run the migrations? (yes/no) [yes] yes
Would you like to load the seed data? (yes/no) [yes] yes
Would you like to load the sample data? (yes/no) [yes] yes
     gemfile  spree
     gemfile  spree_gateway
     gemfile  spree_auth_devise
         run  bundle install from "./my_store"
https://github.com/spree/spree_gateway.git (at 2-0-stable) is not checked out. Please run `bundle install`

Step 3
You have to run bundle install in your rails project.

$ bundle install

You might get error like this:

Bundler could not find compatible versions for gem "jquery-rails":
  In Gemfile:
    spree (= 2.0.3) x86-mingw32 depends on
      jquery-rails (~> 2.0) x86-mingw32

    jquery-rails (3.0.4)

To remove this error , change the gem file to use stable version of spree like this :

gem 'spree', :github => "spree/spree", :branch => "2-0-stable"
gem 'spree_auth_devise', :github => "spree/spree_auth_devise", :branch => "2-0-stable"
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => "2-0-stable"

Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

Step 4
Now run this command to setup database and other things for your spree app :

$ bundle exec rails g spree:install

Step 5
Install mysql gem correctly , otherwise you will get errors like this :

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (cannot load such file -- mysql2)

For installing mysql gem , first uninstall all the version of mysql . Download , connector library for windows(zip format) ,unzip it to a folder , and run the following command :

$ gem install mysql2 --platform=ruby -- '--with-mysql-include=C:\mysql2\include --with-mysql-lib=C:\mysql2\lib --with-mysql-dir=C:\mysql2'

Where mysql2 is the directory containing connector folder.

If you use 64bit version of mysql connector , you might get some errors .

After installing mysql2 , you may get error in brcypt also . Like this :

Polyglot: found more than one candidate for bcrypt: C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.1.1-x86-mingw32/lib/bcrypt, C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcry
Polyglot: found more than one candidate for C:/Users/ACSMAC05/my_store/config/environment.rb: C:/Users/ACSMAC05/my_store/config/environment.rb, C:/Users/ACSMAC05/my_store
C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require': 126: The specified module could not be found.   - C:/Ruby200/lib/ruby/gems/2.0.0/gems/
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:234:in `block in load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:234:in `load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.1.1-x86-mingw32/lib/bcrypt.rb:12:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:234:in `block in load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:234:in `load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models/database_authenticatable.rb:2:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:97:in `const_get'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:97:in `block (2 levels) in devise'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:92:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:92:in `block in devise'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:123:in `devise_modules_hook!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/devise-2.2.4/lib/devise/models.rb:90:in `devise'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree_auth_devise-5826881e4743/app/models/spree/user.rb:5:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree_auth_devise-5826881e4743/app/models/spree/user.rb:2:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree_auth_devise-5826881e4743/app/models/spree/user.rb:1:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `block in load_file'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:468:in `load_file'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:353:in `require_or_load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:502:in `load_missing_constant'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:192:in `block in const_missing'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:190:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:190:in `const_missing'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in `constantize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/core/lib/spree/core.rb:20:in `user_class'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/core/app/models/spree/order.rb:36:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/core/app/models/spree/order.rb:5:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/core/app/models/spree/order.rb:4:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `block in load_file'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:468:in `load_file'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:353:in `require_or_load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:502:in `load_missing_constant'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:192:in `block in const_missing'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:190:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:190:in `const_missing'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/api/app/models/spree/order_decorator.rb:1:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/api/lib/spree/api/engine.rb:23:in `block in activate'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/api/lib/spree/api/engine.rb:22:in `glob'
        from C:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/spree-801c4256880a/api/lib/spree/api/engine.rb:22:in `activate'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:429:in `_run__862172010__prepare__423758158__callbacks'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/application/finisher.rb:47:in `block in '
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from C:/Users/ACSMAC05/my_store/config/environment.rb:5:in `'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:25:in `'
        from script/rails:6:in `require'
        from script/rails:6:in `
'

Uninstall all versions of bcrypt and bcrypt-ruby and reinstall by using following command :

$ gem install bcrypt-ruby -v 3.0.1 --platform=ruby --no-ri --no-rdoc

After removing these errors , this command should work :

$ bundle exec rails g spree:install

It will create all the required files in your rails folder , and create database and also sample data .

Now you can start the server , by typing “rails s” and see sample spree app on your browser http://localhost:3000 .