is there a way of installing therubyracer in windows? - ruby-on-rails

Is there a way of installing therubyracer gem i.e required to run a RoR project in windows?
I've tried normal way, but it wouldn't and then i tried installing cygwin and then tried installing gem, but still no luck,
Anyone successful in installing this in windows?
I can even try the hard methods also (if there're any possible solutions)

I used therubyracer_for_windows. It works for me.

If you need a JS runtime for asset compilation (and other tasks), on Windows it's perfectly safe to simply omit the gem in your Gemfile.
Windows already has a JS runtime, and as far as I am aware, Rails makes use of it when it detects it.
Have a look at the description here, I think you will find it informative.
https://github.com/sstephenson/execjs

Related

How do I force Bundler to get the right libv8-node for mini-racer?

I'm working on a Rails 5->6 update. When I run bundle update, we reach mini_racer, which requires libv8-node. When Bundler tries to get libv8-node v. 15.14.0.1, it tries to install <our local mirror path>/gems/gems-repos/gems/libv8-node-15.14.0.1-x86_64-linux-musl.gem, which is incorrect (this is a Debian VM) and the server responds with an error. gem install libv8-node works just fine.
The ruby-libv8-node page suggests there is a known issue with Bundler picking the wrong platform. Chasing down that rabbit hole it looks like there are proposed solutions but nothing released yet.
In the meantime, is there a workaround for forcing Bundler to use the right platform? This is Bundler 2.2.28 and Ruby 2.6.6.
Based on the README, it says
If a published binary does not work for you, bundler allows to force using the ruby platform via force_ruby_platform, which will compile from source.
so please try
BUNDLE_FORCE_RUBY_PLATFORM=1 bundle install
or BUNDLE_FORCE_RUBY_PLATFORM=1 bundle update rails
I've been dealing with this problem today. Whilst enabling the BUNDLE_FORCE_RUBY_PLATFORM=1 environment variable for bundler will work because it compiles from source, however this will be slow. Compiling libv8-node is no small chunk of code.
An alternative that worked for me was
BUNDLE_SPECIFIC_PLATFORM=1 bundle install
and that pulled the correct pre-compiled x86_64-linux binary for libv8-node. Much faster.
Note, I had already added x86_64-linux to the PLATFORMS section of the lockfile using bundle lock --add-platform x86_64-linux. This is the right thing to do anyway, but I'm not able to say for sure whether the BUNDLE_SPECIFIC_PLATFORM alone was sufficient to resolve or whether it was the combination.

Twitter Bootstrap for Rails 4 on Windows 7

I'm not exactly a seasoned veteran of the Rails world, but from what I've seen, I would definitely like to use bootstrap on my Rails projects.
i'm running windows 7 and I'm kind a married to it. I have read everything I can find on this topic and is it just not possible to install bootstrap-rails on windows?
Every time I try to install either therubyracer or libv8 I get fatal errors that I can't resolve.
It won't install twitter-bootstrap-rails because I don't have those other two.
Can someone either tell me how to install bootstrap on my windows box or point me to the information?
I am so frustrated, i've been stuck with this for a few months now.
Give bootstrap-sass a try. This should get around the need to compile the style sheets into less, since they are ported to sass with this project. See Section A for gems to include in your Gemfile.
Try this:
gem install libv8 -- --with-system-v8
Because libv8 is the interface for the V8 engine used by therubyracer,
you may need to use libv8, even if you have V8 installed already. If
you wish to use your own V8 installation, rather than have it built
for you, use the --with-system-v8 option.
Source
I'm would never suggest cheating on your operating system, I'm just saying you could dual-boot and she would never know.
Bootstrap-Sass works for me too.

Run Rails App In Windows and Linux with different gemfiles

I'm looking for a way to set up my rails app/Gem file to conditionally include a gem based on if I am in linux or not. I need the app in Linux, but it is not compatible with windows and I don't need it there anyway.
I was able to get everything working on Linux, but since I am using LESS stylesheets, I needed a javascript runtime. I didn't want to install Node.js, so i installed therubyracer, which is now in my gemfile. Then I pushed everything to github and cloned the app on my windows computer.
I tried to install all of the gems and realized there was no way install therubyracer on windows because of an incompatibility they haven't fixed yet (see therubyracer gem on windows)
I read elsewhere that I don't need therubyracer on windows because rails will automatically pick up the JScript runtime, so I'd like to have a simple way to only include therubyracer in linux. I read in does using ":platforms =>" in your gemfile work? that I can use an if block in my gemfile, but that it will cause my gemfile.lock to be regenerated every time. That was over a year ago though. Is there a way to only include therubyracer without regenerating gemfile.lock every time? Or maybe is gemfile.lock ok to remove my git and just have it generated every time locally?
I think you'll probably have to use that answer in the :platforms question and just ignore the fact that the gemfile.lock is regenerated. There's not much point in keeping the lockfile in your repository when it will be different on each platform. However, you can still maintain some of the control that the lockfile provides by manually specifying specific versions and dependencies in the gemfile.

rails 3.1 not working for Windows 7 (JavaScript Runtime issue)

I searched around, people say it suppose to work that I don't need javascript runtime on Windows, but it's not working. When I run rails server, it tells me I need runtime and show a link to a github page. Also I tried to install those runtime listed on that github page, including therubyracer, nothing is able to be installed, got errors everywhere. The question is, what should I do to get Rails 3.1 running on Windows 7?
Check this answer: therubyracer gem on windows
You should be using execjs gem instead.
From the execjs page: it should just use the standard Windows javasccript runtime (Jscript).
Set the following environment variable:
export EXECJS_RUNTIME=JScript
or
ENV['EXECJS_RUNTIME'] = 'JScript'.
Hope this helps.
I struggled with this for many hours tonight, doing all sorts of stuff with reinstalling ruby, rails, devkit, trying to include therubyracer or libv8... (I'm sure you've come across all of this by now)
I eventually solved it by: Uninstalling Internet Explorer 9.
I'm now back to the default IE8 and it is working fine.
(Windows 7 Ultimate x64, Service Pack 1, running Ruby 1.9.2p290, Rails 3.1.1, Rubygems 1.8.1.1. Also installed the Devkit and node.js at some stage through this)
Have you thought of using vagrant, that way you can have more than one vm you can control and vm for development and their systems are separate from each other so you have less dependency issues.
And also you'll be running linux so everything should be available for that platform.
You need to install node.js to run the coffeescript compilation used in rails. http://nodejs.org/

Upgrading Ruby broke Rails?

So, I upgraded Ruby to 1.8.7 to make a particular gem work. Hooray, it works now! But...now rails doesn't. I tried reinstalling rails through gem, but that hasn't helped, either. Rake is no longer recognized by my windows box as a valid command, and I can't even start the server without a whole string of errors.
My only thought is that maybe I shouldn't have copied my gems file over (a tutorial mentioned it as the only way to save my gems on windows with an upgrade). I'm gonna try reinstalling 1.8.7 without changing anything, and reinstalling everything as needed.
Edit: Okay, just plain 1.8.7 does work, but it's frustrating to have to reinstall all my gems by hand... Is there any better solution, in Windows?
You may have to uninstall the old version first or use something like RVM to manage your multiple versions. I've always run into problems trying to upgrade directly on a windows machine (rake and rails not working basically).
Edit: Looks like even with RVM you have to install gems individually for each version (a good thing), but you can also export and import gem sets. That might be your best bet, short of scripting a solution yourself.
That is normal: each ruby environment has their own set of gems. That might not seem intuitive, but i guess it has something to do with the possible differences in ruby versions and the fact that gems are "installed" and compiled if needed.
I have a script that installs all my needed gems on windows. On windows rvm does not work, but there is an alternative called pik. I have written a blogpost about this process, which also contains a small bat-file i use that will install the most commonly used gems automatically.

Resources