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

2

6

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.

Puff answered 27/9, 2021 at 19:21 Comment(2)
did you first try gem uninstall libv8-node ?Tullis
@Tullis I did, and it does not help.Puff
A
9

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

Assyrian answered 6/10, 2021 at 13:50 Comment(1)
That got me a successful bundle update (albeit super slow, as did some source compiling of other gems as well). Progress! This may be it!Puff
M
5

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.

Maceio answered 13/7, 2022 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.