50

I've been peacefully developing on Windows without adding any gems for a few weeks now and today I decided to do a bundle update, but I cannot get through this gem called therubyracer. I have the devkit installed and it is working according to the documentation's verification procedure.

My question is: is there a way to install this gem at all on windows?

And is this gem going to be required by rails 3.1 and this is why now that I do a bundle update it is being 'slipped' into the rails 3.0.8 as a gesture of early kick start for future 3.1 migration?

EDIT including Gemfile and Gemfile.lock

# Gemfile
# source 'http://rubygems.org'
source :rubygems

gem 'rails'
gem 'rake', '0.8.7'
gem 'youtube_it'
gem 'panda'
gem "nifty-generators"
# gem "mongoid", "2.0.0.rc.7"
gem "mongoid"
gem "mongoid-eager-loading"
# gem 'mongoid_search'
gem "bson_ext", ">1.1.5"
gem 'devise'
gem 'cancan'
gem 'hirb'
# gem 'heroku'
gem 'rest-client'
gem 'less' # needs the more plugin
# gem 'hash_extension'
gem 'aws-s3', :require => 'aws/s3' # s3.rb
gem 'jquery-rails', ">= 0.2.7" # rails g jquery:install
# gem 'mongrel', ">= 1.2.0.pre2"
gem 'delayed_job'
gem 'delayed_job_mongoid'
gem 'kaminari'



# Gemfile.lock
GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.8)
      actionpack (= 3.0.8)
      mail (~> 2.2.19)
    actionpack (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.8)
      activesupport (= 3.0.8)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
    activesupport (3.0.8)
    arel (2.0.10)
    aws-s3 (0.6.2)
      builder
      mime-types
      xml-simple
    bcrypt-ruby (2.1.4-x86-mingw32)
    bson (1.3.1)
    bson_ext (1.3.1)
    builder (2.1.2)
    cancan (1.6.5)
    daemons (1.1.3)
    delayed_job (2.1.4)
      activesupport (~> 3.0)
      daemons
    delayed_job_mongoid (1.0.2)
      delayed_job (~> 2.1.1)
      mongoid (~> 2.0.0.rc)
    devise (1.3.4)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    hirb (0.4.5)
    i18n (0.5.0)
    jquery-rails (1.0.10)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.5.2)
    kaminari (0.12.4)
      rails (>= 3.0.0)
    less (1.2.21)
      mutter (>= 0.4.2)
      treetop (>= 1.4.2)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    mongo (1.3.1)
      bson (>= 1.3.1)
    mongoid (2.0.2)
      activemodel (~> 3.0)
      mongo (~> 1.3)
      tzinfo (~> 0.3.22)
    mongoid-eager-loading (0.3.1)
    mutter (0.5.3)
    nifty-generators (0.4.6)
    oauth (0.4.4)
    orm_adapter (0.0.5)
    panda (1.4.2)
      json
      rest-client
      ruby-hmac (>= 0.3.2)
    polyglot (0.3.1)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.8)
      actionmailer (= 3.0.8)
      actionpack (= 3.0.8)
      activerecord (= 3.0.8)
      activeresource (= 3.0.8)
      activesupport (= 3.0.8)
      bundler (~> 1.0)
      railties (= 3.0.8)
    railties (3.0.8)
      actionpack (= 3.0.8)
      activesupport (= 3.0.8)
      rake (>= 0.8.7)
      thor (~> 0.14.4)
    rake (0.8.7)
    rest-client (1.6.1)
      mime-types (>= 1.16)
    ruby-hmac (0.4.0)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.28)
    warden (1.0.4)
      rack (>= 1.0)
    xml-simple (1.0.16)
    youtube_it (1.4.2)
      builder
      oauth (>= 0.4.4)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  aws-s3
  bson_ext (> 1.1.5)
  cancan
  delayed_job
  delayed_job_mongoid
  devise
  hirb
  jquery-rails (>= 0.2.7)
  kaminari
  less
  mongoid
  mongoid-eager-loading
  nifty-generators
  panda
  rails
  rake (= 0.8.7)
  rest-client
  youtube_it
Community
  • 1
  • 1
Nik So
  • 16,683
  • 21
  • 74
  • 108
  • 1
    Are you deploying the app on Windows too? If not (e.g. you're deploying to Heroku) then you can remove the dependency on therubyracer in your Windows environment. Happy to expand if this is your scenario. – Dominic Sayers Jul 14 '11 at 17:42
  • @Dominic Sayers -- No, not on Windows, but yes on Heroku. My guess is, if I don't directly interact with a gem which cannot be installed at all on Windows, but Heroku being Linux so it should be fine. So I don't exactly know how to exclude it from the dependencies a Rails app. I mean, I never specified it in my Gemfile in the first place. It just sort of popped up in my "bundle update" one day. Thanks! – Nik So Jul 16 '11 at 20:31

5 Answers5

67

No, there is no way that I know of to currently install this gem on Windows. The problem is that there is currently no pre-compiled version of the libv8 gem for Windows, and the source version is only compatible with *nix. It does not necessarily have to be that way, it just requires somebody taking the time to make the compile work for Windows. https://github.com/cowboyd/libv8

That said, Windows should come with a JScript, the Microsoft JavaScript runtime, which Rails (via execjs) will automatically detect and use, so you should be able to just remove your dependency on therubyracer.

As the maintainer of that gem, this would of course make me sad, but it should get you on your way.

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
Charles Lowell
  • 1,157
  • 8
  • 10
  • Oh wow, what a pleasure to have you (the maintainer) to answer my question THANKS!! -- Thanks for the execjs hint, I will look it up. Sorry to be a bother, do you happen to know how one can find out gem denpendencies in Rails? – Nik So Jun 15 '11 at 20:56
  • Nik, If all you're doing is using the vaniall Rails 3.1 asset pipeline with coffeescript, then you *should* be able to just use the execjs gem which will delegate detect that you are on Windows and use the Microsoft JScript interpreter. Then you wouldn't need to have therubyracer in your Gemfile at all. – Charles Lowell Jul 17 '11 at 03:17
  • I have been able to update the Gemfile through "bundle update development" -- Reason: I have this line which is scoped to the :production group of the Gemfile that installs therubyracer as I read somewhere that it is needed for Heroku ( whether or not it is still needed, I am unsure) so everytime I do a plain "bundle update" the same error gets thrown, but if I do the above "bundle update development" it works. --- I have read quite a handful of blog posts that basically reiterate what you're saying, that execjs should kick in and tell rails to use native MS engine, but not true... – Nik So Jul 18 '11 at 05:42
  • Hi Nik, this was basically the solution I was going to propose. I think it's OK - you're developing on one environment and deploying on another so the gem sets may well be different. If you're hoping it will infer the environment automagically then I don't know a way of doing that. But I'm not a Rails guru so it might be possible. – Dominic Sayers Jul 22 '11 at 20:57
  • 19
    Hi, just to add a quick note: You can write `gem 'therubyracer', :platform => :ruby` in your Gemfile, so that `therubyracer` is only installed on linux and OSX, but NOT Windows. – ndbroadbent Jan 04 '12 at 08:09
  • 1
    Nathan, that's true but under cygwin you are in windows and :platform => :ruby has no effect – Rafa de Castro Jul 24 '12 at 12:29
  • The `libv8` project can now be found here: https://github.com/cowboyd/libv8. At the time of writing, there is an open issue regarding Windows support: https://github.com/cowboyd/libv8/issues/217 – Tom Lord Feb 07 '17 at 13:57
13

This is essentially what Nik has done, I believe:

In your Gemfile isolate the TheRubyRacer gem to the production environment like this:

group :production do
  gem 'therubyracer-heroku', :platform => :ruby
end

In your development environment, instead of a plain bundle install do

bundle install --without production

or, as Nik suggests, bundle install development. When you deploy to Heroku it will install the gem because it is the production environment.

Rails gurus: please suggest edits to make this less sucky.

Dominic Sayers
  • 1,783
  • 2
  • 20
  • 26
  • Yes, indeed. The Gemfile I've been using the past couple of weeks looks similar and I do do "bundle install development" to avoid any error messages. I do hope the Rails core team will bestow adjustment to Rails so to make general Rails installation/ussage across the three main platform essentially the same. Thanks for keeping coming back to this question Dominic – Nik So Jul 23 '11 at 04:30
  • 2
    You could add `gem 'therubyracer', :platform => :ruby` in your Gemfile, so that `therubyracer` is only installed on linux and OSX, and not Windows – ndbroadbent Jan 04 '12 at 08:14
  • Thanks for the suggestion nathan.f77. I've edited my answer as you suggest. – Dominic Sayers Jan 05 '12 at 17:00
11

The reason for all of these problems is the therubyracer-0.11.0beta1-x86-mingw32.gem and the v8.dll.

I have complied the necessary dlls and gem files and upload them to github.

download the package and follow the instructions.

https://github.com/eakmotion/therubyracer_for_windows

jaytho
  • 100
  • 8
Hiran
  • 257
  • 3
  • 7
  • I tried what you said on the instructions and I'm getting message Successfully installed therubyracer-0.11.0beta1-x86-mingw32 1 gem installed Installing ri documentation for therubyracer-0.11.0beta1-x86-mingw32... Installing RDoc documentation for therubyracer-0.11.0beta1-x86-mingw32... and copied the dll files, to bin folder, restarted machine 3 times. I'm running on windows 7. Still bundle install shows error. – Jay Dec 16 '12 at 22:09
  • put less-rails gem in your bundle file and run bundle install ex :- gem 'less-rails' gem 'therubyracer' – Hiran Jan 22 '13 at 05:04
  • 1
    @Hiran I tried it under my C:\RailsInstaller\Ruby1.9.3\bin but it wont work..let me know how do i fix it..im still struggling in removing this therubyracer problem – swapnesh May 11 '13 at 13:57
  • 1
    The instructions in your link work flawlessly on Windows7 64bit. Thanks! – thinkOfaNumber May 15 '13 at 04:50
  • Getting `v8_context.rb:2:in require': cannot load such file -- v8 (LoadError) on running rails server`. Besides, I don't see libv8 in the Gemfile.lock – bad_keypoints Dec 14 '13 at 19:55
4

There is build for windows. It can be manually downloaded and installed by gem install therubyracer-0.11.0beta1-x86-mingw32.gem.

Alex
  • 633
  • 1
  • 5
  • 10
  • `ERROR: Could not find a valid gem 'therubyracer-0.11.0beta1-x86-mingw32.gem' (>= 0) in any repository` – blockloop Oct 23 '12 at 21:19
  • 4
    **NOTE:** you have to download the gem to your local directory and reference it locally Download link: https://github.com/downloads/stereobooster/therubyracer/therubyracer-0.11.0beta1-x86-mingw32.gem – blockloop Oct 23 '12 at 21:22
  • @blockloop can you tell me how you did this? I cloned the directory, followed the instructions. Didn't work. Then I read your thing, and in Gemfile pointed the path to where I saved therubyracer-0.11.0beta1-x86-mingw32.gem. But when I run bundle it doesn't detect it. – Ka Mok Jul 20 '16 at 21:20
2

To answer part of your question about Rails 3.1, here's the deal...

Rails 3.1 currently uses a gem that requires a javascript runtime to be installed on the machine. On Mac you typically don't have to worry about this since it already has one, but Linux (and I think Windows too) you need to install one. So, therubyracer, or sometimes node or nodejs, are sometimes installed since they provide that.

However, one of the main Rails guys said they plan to fix that dependency before the final Rails 3.1 release, so hopefully that'll happen and the dependency will be gone.

jdc
  • 733
  • 3
  • 7
  • I see so Rails 3.1 does/will require that probably for the asset packaging thing. Since you mention about the nodejs, I've heard that they *might* have a version for windows, I'm just going to what-the-hell install it on my computer first to see if rails "detects" it and ignore installing therubyracer (for now). Thank you – Nik So Jun 15 '11 at 20:58