rubyjs / libv8

Ruby gem binary distribution of the V8 JavaScript engine
269 stars 121 forks source link

Chromium's depot_tools are not able to fetch V8's source on Alpine Linux #259

Closed niko closed 11 months ago

niko commented 6 years ago

I'm getting an error when trying to install libv8. I'm using Ruby 2.5.0 on Alpine Linux. It seems to be a problem with downloading the sources.

gem install libv8                                                                                                                                                                                              Building native extensions. This could take a while...
ERROR:  Error installing libv8:
    ERROR: Failed to build gem native extension.

    current directory: /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8
/usr/bin/ruby -r ./siteconf20180625-7743-1i7w51g.rb extconf.rb
creating Makefile
Running: gclient root
Error: Command 'download_from_google_storage --no_resume --platform=linux* --no_auth --bucket chromium-clang-format -s v8/buildtools/linux64/clang-format.sha1' returned non-zero exit status 1 in /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor
Running: gclient config --spec 'solutions = [
  {
    "url": "https://chromium.googlesource.com/v8/v8.git",
    "managed": False,
    "name": "v8",
    "deps_file": "DEPS",
    "custom_deps": {},
  },
]
'
Running: gclient sync --with_branch_heads
Traceback (most recent call last):
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 301, in <module>
    sys.exit(main())
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 296, in main
    return run(options, spec, root)
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 290, in run
    return checkout.init()
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 133, in init
    self.run_gclient(*sync_cmd)
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 78, in run_gclient
    return self.run(cmd_prefix + cmd, **kwargs)
  File "/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/vendor/depot_tools/fetch.py", line 68, in run
    return subprocess.check_output(cmd, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '('gclient', 'sync', '--with_branch_heads')' returned non-zero exit status 2
/usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8/builder.rb:117:in `block in setup_build_deps!': unable to fetch v8 source (RuntimeError)
    from /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8/builder.rb:115:in `chdir'
    from /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8/builder.rb:115:in `setup_build_deps!'
    from /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8/builder.rb:71:in `build_libv8!'
    from /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1/ext/libv8/location.rb:24:in `install!'
    from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/2.5.0/gems/libv8-6.3.292.48.1 for inspection.
Results logged to /usr/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/libv8-6.3.292.48.1/gem_make.out
niko commented 6 years ago

Strange enough install in the docker ruby:2.5-alpine container just works:

$ docker run -it ruby:2.5-alpine gem install libv8                                                                                                                                                                                                                                                                                                   
Fetching: libv8-6.3.292.48.1-x86_64-linux.gem (100%)
Successfully installed libv8-6.3.292.48.1-x86_64-linux
1 gem installed

Notable similarities: It's the exact same version. Notable difference: It's not building native extensions. And that's where my local install fails. gem version is 2.7.7 in docker and 2.7.6 native.

ignisf commented 6 years ago

There seems to be lack of upstream support of the SDK with Alpine at this point:

Reference issues:

Star those issues to help get them resolved or even better -- suggest patches.

niko commented 6 years ago

Any idea why this just works within a docker container?

ignisf commented 6 years ago

Hey, it does not.

If you take a closer look, gem downloads the Linux binary version Fetching: libv8-6.3.292.48.1-*x86_64-linux*.gem (100%)

This has been linked against glibc, which makes it unusable on Alpine afaik. :(

ignisf commented 6 years ago

Huh... Actually it might work -- the Dockerfile you're using downloads and compiles Ruby from source which I think is linked against glibc... https://github.com/docker-library/ruby/blob/699a04311386ecc98ca242fc9bdee17fb4008863/2.5/alpine3.7/Dockerfile

The Ruby in Alpine's repos is not and in fact is patched to not use binary versions of gems because of the reason I outlined in the comment above.

niko commented 6 years ago

Oh. Right. That makes sense.

lloeki commented 4 years ago

Made a comment here regarding musl support and a possible partially upstream solution: https://github.com/rubyjs/libv8/issues/270#issuecomment-573063347

lloeki commented 11 months ago

Closing as this issue is completely sidestepped in libv8-node, and has musl builds.