Install therubyracer / libv8

8 posts / 0 new
Last post
#1 Mon, 2016-03-21 22:48
atwoodjw
  • atwoodjw's picture
  • Offline
  • Last seen: 1 year 12 months ago
  • Joined: 2016-03-21

Has anyone been able to successfully get the libv8 gem to work on Alpine?

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)

Mon, 2016-03-28 23:33
jirutka
  • jirutka's picture
  • Offline
  • Last seen: 2 years 3 days ago
  • Joined: 2016-03-28

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.

Mon, 2016-04-04 19:01
atwoodjw
  • atwoodjw's picture
  • Offline
  • Last seen: 1 year 12 months ago
  • Joined: 2016-03-21

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.

apk add --update v8
fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch" rel="nofollow">http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch</a> <a href="http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
fetch" rel="nofollow">http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
fetch</a> <a href="http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
ERROR:" rel="nofollow">http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
ERROR:</a> unsatisfiable constraints:
  v8-3.26.31.15-r3:
    masked in: @testing
    satisfies: world[v8]
  so:libicudata.so.55 (missing):
    required by: v8-3.26.31.15-r3[so:libicudata.so.55] v8-3.26.31.15-r3[so:libicudata.so.55]
  so:libicui18n.so.55 (missing):
    required by: v8-3.26.31.15-r3[so:libicui18n.so.55] v8-3.26.31.15-r3[so:libicui18n.so.55]
  so:libicuuc.so.55 (missing):
    required by: v8-3.26.31.15-r3[so:libicuuc.so.55] v8-3.26.31.15-r3[so:libicuuc.so.55]

Wed, 2016-04-06 14:02
rollbrettler
  • rollbrettler's picture
  • Offline
  • Last seen: 1 year 11 months ago
  • Joined: 2016-04-06

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

echo "@oldmain <a href="http://dl-3.alpinelinux.org/alpine/v3.2/main"" rel="nofollow">http://dl-3.alpinelinux.org/alpine/v3.2/main"</a> >> /etc/apk/repositories
apk add --update icu-libs@oldmain icu-dev@oldmain

Mon, 2016-06-13 11:52
ehekatl
  • ehekatl's picture
  • Offline
  • Last seen: 1 year 9 months ago
  • Joined: 2016-06-13

I did all of this, bundle install libv8 with system v8, still getting `Gem Load Error is: uninitialized constant V8::JSError`, any help ?

Wed, 2016-06-15 04:28
gphillips
  • gphillips's picture
  • Offline
  • Last seen: 1 year 9 months ago
  • Joined: 2016-06-14

Is there any update on this issue?

Sat, 2016-12-03 23:32
spaquet
  • spaquet's picture
  • Offline
  • Last seen: 1 year 3 months ago
  • Joined: 2016-12-03

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)

Sat, 2017-02-04 04:04
usualoma
  • usualoma's picture
  • Offline
  • Last seen: 1 year 1 month ago
  • Joined: 2017-02-04

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.

Log in or register to post comments