Install therubyracer / libv8
#1
Mon, 2016-03-21 22:48
atwoodjw
-
- Offline
- 1 year 12 months ago
- 2016-03-21
Has anyone been able to successfully get the libv8 gem
There's an alpine variant of the official ruby Docker image (ruby:alpine), which is great for deploying Rails apps. However, I can't use therubyracer gem to compile *.less files without the libv8 gem. While it installs without issue, I see the following when running RUN RAILS_ENV=production SECRET_KEY_BASE=secret bundle exec rake assets:precompile
.
LoadError: Error relocating /usr/local/bundle/gems/therubyracer-0.12.2/lib/v8/init.so: __isnan: symbol not found - /usr/local/bundle/gems/therubyracer-0.12.2/lib/v8/init.so /usr/local/bundle/gems/therubyracer-0.12.2/lib/v8.rb:4:in `require' /usr/local/bundle/gems/therubyracer-0.12.2/lib/v8.rb:4:in `<top (required)>' /usr/local/bundle/gems/therubyracer-0.12.2/lib/therubyracer.rb:1:in `require' /usr/local/bundle/gems/therubyracer-0.12.2/lib/therubyracer.rb:1:in `<top (required)>' /app/config/application.rb:12:in `<top (required)>' /app/Rakefile:4:in `require' /app/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)
libv8 is written in C/C++, so you should install it from Alpine package or manually from sources, not from a gem (it doesn’t handle system dependencies). There’s no standalone libv8 package in Alpine, but it’s included in nodejs package.
To compile *.less files, you actually don’t need therubyracer at all – just install nodejs and exclude therubyracer. The LESS compiler should be able to use system-provided nodejs when it’s available.
Thanks for the suggestion.
To use *.less in the Rails asset pipeline (with all the various helpers, etc.), you have to use rails-less, which requires therubyracer... which requires libv8. So I think I'm stuck with trying to get stand-alone v8 installed, so I can tell libv8 to use the system v8.
bundle config build.libv8 --with-system-v8
I see that there actually is a standalone v8 package in test testing repository, but I can't get it to install.
Hey I ran into the same problem. The testing V8 package is out of date and linked to libicu 55 and the latest main package is 56. The way I solved this issue so far: I pinned the packages icu-libs and icu-dev to the v3.2 main repository
I did all of this, bundle install libv8 with system v8, still getting `Gem Load Error is: uninitialized constant V8::JSError`, any help ?
Is there any update on this issue?
RUN apk --update add --virtual .build-dependencies build-base ruby-dev \
openssl-dev libxml2-dev libxslt-dev \
postgresql-dev libc-dev linux-headers nodejs tzdata
But till fail. What should be imported NodeJS or NodeJS-Dev (I also tried the second and it failed the same way)
I've got solution.
We should compile the libv8 gem manually on the alpine linux.
https://hub.docker.com/r/usualoma/ruby-with-therubyracer/builds/bmp6m8xaohdyawebk5cvgx5/
I've install and use therubyracer by that Dockerfile.