32

I'm getting a cyclic error here:

Bundler::GemspecError: Could not read gem at /path/to/website/vendor/cache/ruby/2.1.0/cache/libv8-3.16.14.7-x86_64-darwin-14.gem. It may be corrupted.
An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

$ gem install libv8 -v '3.16.14.7'

Successfully installed libv8-3.16.14.7-x86_64-darwin-14
/Users/snowcrash/.rvm/gems/ruby-2.1.5/gems/rdoc-4.0.1/lib/rdoc/markdown.rb:15931: warning: encountered \r in middle of line, treated as a mere space
Parsing documentation for libv8-3.16.14.7-x86_64-darwin-14
Done installing documentation for libv8 after 0 seconds
1 gem installed

$ bundle install --path vendor/cache
... many lines here ...
Using koala (1.10.1) 

Bundler::GemspecError: Could not read gem at /path/to/website/vendor/cache/ruby/2.1.0/cache/libv8-3.16.14.7-x86_64-darwin-14.gem. It may be corrupted.
An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

Any suggestions?

==== UPDATE

I tried deleting all cache data with rm -rf ~/.rvm/gems/ruby-2.1.5/cache/ and now bundle install --path vendor/cache gives me:

Bundler::GemspecError: Could not read gem at /path/to/website/vendor/cache/ruby/2.1.0/cache/libv8-3.16.14.7-x86_64-darwin-14.gem. It may be corrupted.
An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.
David Hempy
  • 5,373
  • 2
  • 40
  • 68
Snowcrash
  • 80,579
  • 89
  • 266
  • 376

5 Answers5

61

For MacOS Catalina, Big Sur, and Monterey:

brew install v8@3.15
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
bundle

(update version numbers as needed)

David Hempy
  • 5,373
  • 2
  • 40
  • 68
29

Facing the same issue, install gem with system preferences worked for me

gem install libv8 -v '3.16.14.7' -- --with-system-v8
shilovk
  • 11,718
  • 17
  • 75
  • 74
S.D
  • 485
  • 5
  • 8
14

Usually the solution for this is updating libv8 to the latest version:

bundle update libv8

Guilherme Garnier
  • 2,208
  • 23
  • 22
11

Run the following bundle config command then run bundle again

bundle config build.libv8 --with-system-v8
6

Run the following command than run the bundle install again.

rm ~/.rvm/gems/ruby-2.1.2/cache/libv8-3.16.14.7-x86_64-linux.gem
David Hempy
  • 5,373
  • 2
  • 40
  • 68
Ajeet Khan
  • 8,582
  • 8
  • 42
  • 65