Lazy symbol binding failed Ruby Racer - macos

I'm running El Capitan (Fresh install) and a Rails 4.2.1 app with Ruby 2.2.2. I've ran into issues initially with installing libv8 and had to force an install with brew install v8 and gem install libv8 (version) with systemv8 as a flag. Bundle works fine and installs all the gem dependencies.
But when I go to load rails s or bundle exec thin start to launch my app server I get the following error.
dyld: lazy symbol binding failed: Symbol not found: __ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_
Referenced from: /Users/shakycode/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/therubyracer-0.12.2/v8/init.bundle
Expected in: flat namespace
dyld: Symbol not found: __ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_
Referenced from: /Users/shakycode/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/therubyracer-0.12.2/v8/init.bundle
Expected in: flat namespace
I'm googling and searching for answers but haven't come up with much that works so far. My other machine which was an upgrade to El Capitan works no problem, but this clean install is problematic with libv8/v8/therubyracer.
Any thoughts on how I can debug this one? I want to code.

Just reinstalling therubyracer also did not work for me. Complete instructions:
gem uninstall therubyracer libv8
gem install libv8 therubyracer -- --with-system-v8

I've just had this problem as well and I solved it by uninstalling and reinstalling therubyracer like so:
gem uninstall therubyracer
gem install therubyracer -v '0.12.2' -- --with-system-v8
For me it was triggered by an update to libv8 in the Gemfile. bundle install appeared to run without any problem after the update but I was seeing the same error as the OP whenever I tried to do anything on the command line.

I faced similar error with mini_racer gem. I updated the version from 3.0.1 to 4.0.0 and it worked. Not getting any error now. Mostly it is the problem of version. Sometimes the version of the gem is not compatible with our OS version and this problem can occur.
I was using macOS Sur. Many old versions of gems are not compatible with it.

Related

ruby gem nokogiri version 1.12.5 install error: 'gumbo.h' file not found

I tried changing the gemfile to use a newer version of nokogiri as well as resolve dependencies by brew installing libxml2 and libslt, but nothing worked. Here is the error message:
gumbo.c:32:10: fatal error: 'gumbo.h' file not found
#include "gumbo.h"
^~~~~~~~~
1 warning and 1 error generated.
make: *** [gumbo.o] Error 1
I had the same issue. Not a satisfying answer, but I uninstalled everything and did a clean install using rbenv and it worked.
I had a similar problem. After reading the nokogiri installation instructions, I learned something!
Nokogiri provides precompiled binaries for most things. Now if you switch from Mac to Linux or vice versa, your Gemfile.lock may have a platform list which doesn't include your current platform.
The command that fixed it for me was
bundle lock --add-platform arm64-darwin
Then, bundle just downloaded the precompiled version.
My recommendation is to work out how to install the precompiled version for your platform. When I ran gem install nokogiri that is what happened, but because of the platform list in the Gemfile.lock it wasn't doing that and instead wanted to compile it.
The solution for me on my M1 Macbook was by using rbenv but first:
Uninstall bundler: gem uninstall bundler
Uninstall rbenv: rbenv uninstall YourRubyVersion and then brew uninstall rbenv
(YourRubyVersion you can find it by executing ruby -v)
Delete the Gemfile.lock file.
After that:
brew install rbenv
rbenv install RubyVersion
rbenv init
rbenv global RubyVersion
bundle install

libv8 with ruby on FreeBSD 12

I'm trying to get a ruby app working on FreeBSD 12 but I seem to fail miserably.
I installed v8 via pkg install v8 and tried to install the libv8 gem via this command:
gem install libv8 -v '7.3.492.27.1' -- --with-system-v8
This seems to work fine until it calls gclient which refuses to run on FreeBSD with
KeyError: 'freebsd12'
I search a lot but could not find any solution to the problem. Is there any way to get libv8 working on FreeBSD?
Based on comments in this issue in libv8 repo there are no binary gems for FreeBSD after version 6.0.
You could try to build from source or use downgraded version

Issue with Ruby gems (broken?) trying to get compass to work in npm

I am not a Ruby expert but wanted to figure out what is going on as I am trying to get compass working in a node app but my Ruby seems broken. Typing:
ruby --version
gets me:
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
I have Homebrew installed and have previously had issues with Ruby versions but it seems like it is installed and working. However when I enter a request with gem I get this error:
$ gem -h
Error loading RubyGems plugin "/Users/user_dir/.rvm/gems/ruby-2.1.1#global/gems/executable-hooks-1.3.1/lib/rubygems_plugin.rb": dlopen(/Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle (LoadError)
Error loading RubyGems plugin "/Users/user_dir/.rvm/gems/ruby-2.1.1#global/gems/gem-wrappers-1.2.4/lib/rubygems_plugin.rb": dlopen(/Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib in /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/user_dir/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle (LoadError)
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]
Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install
Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help platforms show information about platforms
gem help <COMMAND> show help on COMMAND
(e.g. 'gem help install')
gem server present a web page at
http://localhost:8808/
with info about installed gems
Further information:
http://guides.rubygems.org
I noticed the reference to openssl but couldn't find any issues online about that.
I have tried installing compass on npm and RVM and Homebrew, so, at the moment, I don't know what versions are being used and where to begin trying to resolve the issue.
If you know what the issue is please let me know, or if you need further info about my system.
I looked at: "Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)" and
"Error loading RubyGems plugin ,openssl.bundle (LoadError)".
I didn't add npm or node tags as I am quite sure it is a Ruby issue, but left it in the question as I did try to install compass there as well.
I have tried fixing RVM, Homebrew etc., but it is still broken.
Are you using brew?
If so, brew update or brew upgrade breaks the Ruby runtime which is what caused a similar error for me.
The following solved the issue for me:
brew rm openssl
brew cleanup openssl
brew install openssl
rvm reinstall ruby
gem install compass
EDIT:
I finally found out that RVM has a default version, so every time I installed a new version it would revert to the old one (I guess this one had errors which is why I didn't notice the version issue).
If you go to:
~/.rvm/gems/
There will be a list of ruby versions and a default folder at the top. Following this page and entering:
rvm --default use 2.1.5
Fixed my problems (for now...)
ORIGINAL:
I tried a lot of different things but eventually got it to work, I have broken this answer down into the list of things I think may have contributed to the result as there were lots of things that didn't work.
This answer to an SO question I found led me down this path.
I reinstalled ruby but because the version in the answer(1.9.3) was older than 2.1.1p76 I just entered:
rvm get stable
then:
rvm reinstall ruby
this kept me on 2.1.1p76, then:
rvm gemset pristine
upgraded gem to 2.4.3
This bit is strange but I then tried to install compass in NPM and it worked but still would not run, then checking my ruby version again gave me 2.1.5p273 (there were no upgrades in between unless RVM gemset pristine updated ruby...).
I then tried the mygemset code from the SO answer but got more errors so I decided to just run
gem install bundler
This seemed to work, so I tried:
gem install compass
Which I had tried many times but this time it worked. It installed ffi-1.9.6.gem and 9 gems which I assume were dependancies.
The NPM package then worked and I currently don't have any errors showing up in ruby.
NOTE: I am not going to accept this answer as I don't really know why it worked, if you follow this be aware I don't know ruby and this was just to get compass working in NPM.
NOTE: Many answers had rbenv as a package manager, I wanted to resolve the situation with what was already on the system so I continued to work with RVM.

Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'

I was trying run gem install json and got the following error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [generator.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/boxen/repo/.bundle/ruby/2.0.0/gems/json-1.8.0 for inspection.
Results logged to /opt/boxen/repo/.bundle/ruby/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.0/gem_make.out
I'm using:
Os X: 10.9.2
Xcode: 5.1 Build version 5B130a
Command Line Tools (CLT): 5.1.0.0.1.1393561416
Ruby: ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Ruby Gem: 2.2.2
GCC: 4.2.1 Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
I am encountering the exact same problem after updating Xcode to 5.1 and news from Apple aren't good. From Xcode 5.1 Release Notes:
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:
-Wno-error=unused-command-line-argument-hard-error-in-future
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
It seems that all gems violating the compiler options must be updated to use valid options. It is explicitly stated that: This option [downgrading error to warning] will not be supported in the future.
The clang note we are seeing (this will be a hard error (cannot be downgraded to a warning) in the future) corresponds to the change announced in the release notes.
To answer your question specifically, use the following to install the json gem:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
Note, however, that this is only a temporary fix.
One-liner to fix that
curl https://gist.githubusercontent.com/Paulche/9713531/raw/1e57fbb440d36ca5607d1739cc6151f373b234b6/gistfile1.txt | sudo patch /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb
To address the issue you can install the most recent version of ruby as described by #Sash. You can use the following commands to do so. In case you already have installed rvm, you don't need to reinstall it.
#Install rvm
\curl -sSL https://get.rvm.io | bash -s stable
#Install ruby version 2.0.0-p451
rvm install ruby-2.0.0-p451
#Print ruby version to verify that it was installed successfully
ruby -v
#Install json gem
sudo gem install json
Issue already addressed by Ruby:
https://bugs.ruby-lang.org/issues/9624
now we just need to wait for Apple to update their ruby version (2.0.0p247) to the one after the latest one (2.0.0p451) which hasn't come out yet ...
(or brew/macport it)
Update (2014-05-15): Mavericks 10.9.3 updates ruby to
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
And this seems to resolves the issue.
#Muncken has already provided an answer to install gem one by one:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
Base on Muncken's answer, I've tried that it also works when using bundle install
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install
In my case, I actually have similar problem, but not on the system ruby, but on rubies installed by rvm from OSX 10.8, and it has issues after upgrading to OSX 10.9.
A simple reinstall works: rvm reinstall ruby-2.1.1
On OSX 10.10, I had several issues when running rails new firstapp such as:
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
fatal error: 'ruby/config.h' file not found
I updated rvm with this configuration and all the errors are gone!:
rvm get stable --auto-dotfiles
You can tell from the app name that I just started fiddling with Ruby on Rails, so the above advice may or may not work for you.
Paul Chechetin's one-liner doesn't appear to work anymore (9/21/15). However, this reply to the post mentioned in Pete's reply solved the problem for me:
(a) Install Apple's XCode, then (b) launch it and accept the licensing terms (I had done (a), but not (b).)
sudo gem uninstall compass
sudo gem install compass
None of these worked for me.
What finally worked is running the command with a sudo -
gem install byebug -v '9.0.6'
It's been a while and I've got similar error. An alternative to folks using bundler is to add the flag to the build configuration like below example:
bundle config build.<gemname> --with-cflags="-Wno-error=implicit-function-declaration"
followed by
bundle install
Please note that you must replace <gemname> above with the name of the actual gem that is throwing the error while building native extensions.
I hope this becomes helpful to others that face similar issues in the future!
I used a simple solution... install through brew
brew install name

`gem install therubyracer` fails on Mac OS X Lion

I would appreciate some help in getting gem install therubyracer to work. Here is the error:
$ gem install therubyracer
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/david/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for main() in -lobjc... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/david/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-objclib
--without-objclib
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)
Here are some notable steps that I ran before the error. They worked fine:
$ gem install libv8
$ brew install v8
My environment is:
Mac OS X Lion 10.7.4
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] (via rvm)
V8 version 3.9.24 (via homebrew)
This worked for me:
$ gem uninstall libv8
$ gem install therubyracer
(A big thanks to http://www.ruby-forum.com/topic/4306127)
gem uninstall libv8
brew install v8
gem install therubyracer
But, why is this happening, you ask? And why does uninstalling libv8 and reinstalling therubyracer fix the problem?
The answer is at the bottom of the error message (from orig post). Ignore the stuff about
probably lack of necessary libraries and/or headers
This is an incorrect assumption by whoever wrote that error message. At the bottom, you see what Ruby has to say about it:
undefined method `include_path' for Libv8:Module
In my case, I was trying to install therubyracer-0.9.8 with bundle install, and for some reason, it was trying to use my copy of libv8-3.11.8.13, which had been installed at some point, probably as a dependency of some other gem.
I don't know why it was trying to use the newer version, because therubyracer.gemspec contains s.add_dependency "libv8", "~> 3.3.10". And my Gemfile.lock says to use libv8 (3.3.10.2). But alas, that is indeed what was happening.
And it's true that Libv8:Module does not have the method include_path in libv8-3.11.8.13, but it does in libv8-3.3.10.2
So that is why uninstalling all of your versions of libv8 and then re-installing therubyracer works. Because all the versions of libv8 that do not have the method include_path are removed completely, and the libv8 that does have the method include path is reinstalled when you reinstall of therubyracer.
Considering none if the above worked for me 100%, I thought I'd post what did (as part of a rails project):
gem uninstall libv8
bundle update therubyracer
This made sure I got the latest therubyracer, and also a more recent version of libV8, and seem to fix the multiple issues I was hitting, from missing libv8.a files, to undefined methods.
At last I use therubyracer 0.11.0beta5 as a solution.
Using therubyracer (0.11.0beta5)
add following on Gemfile
gem 'therubyracer', '~> 0.11.0beta5'
group :libv8 do
gem 'libv8', "~> 3.11.8"
end
then bundle install
Mac OSX 10.8 Moutain Lion
If you need 0.11.3 and it's failing give this a shot for Mac OS X 10.9...
gem uninstall libv8
brew install v8
gem install libv8 -- --with-system-v8
gem install therubyracer -v '0.11.3' -- --with-system-v8
See this issue for more details.
You probably don't need the -- --with-system-v8 on the last line but I did it just to be safe since I saw it start doing Fetching: libv8-3.11.8.17-x86_64-darwin-13.gem (1%) when I ran the command...
Anyhow, it worked for me when all the other things did not.
For anyone encountering this issue on Mac OSX 10.8 Mountain Lion when attempting to upgrade their Gemfile with gem 'therubyracer', '0.11.0', just upgrading the system libv8 gem worked for me (no uninstallation of any other gem necessary):
$ gem update libv8
$ bundle install
Edit
If you use Travis-CI (or other CI tools located on other servers, I assume), you will need to explicitly add the libv8 gem to your Gemfile as well:
Gemfile
gem 'libv8', '3.11.8.3'
then bundle install as usual. Just note that libv8 can take a significant amount of time to install and I've noticed that it may end up being the cause of going over Travis CI's timeout limits, causing your build to fail. You can mitigate this slightly be not including development environment gems in your builds:
.travis.yml
# ...
bundler_args: --binstubs=./bundler_stubs --without development
Update
Yep, pretty much all my Travis builds timeout and fail because of this. If anyone knows a way to solve this problem (I would hope "downgrade therubyracer" is a last resort), please leave a comment!
Update 2
This may not work for all apps, but it seems that my Rails 3.2.9 apps didn't actually need therubyracer or libv8 after all. After removing those gems from my Gemfile, I confirmed that my specs passed, pushed again to Travis and it built successfully. So, I guess getting rid of those gems (if you're not sure you actually need them) is at least worth a try.
Update 3
Thanks to Paul Annesley for confirming that if you're on Mac OS X 10.8 Mountain Lion, you don't need therubyracer gem at all since the OS already comes bundled with Apple JavaScriptCore, its own Javascript runner. At the time of the original answer, I was on Snow Leopard and hence needed it.
For me, removing the Gemfile.lock file and running bundle install worked it's magic.
OSX 10.8.2, ruby 1.9.3p125
None of the above worked for me... I got tired of trying to find the right gem for my environment, so I just soft linked to the g++ target this things was missing:
sudo ln -s `which g++` /usr/bin/g++-4.2
Not as helpfully for remote deployments, but get the job done on my workstation.
I got a similar issue, but it was also complaining about not finding g++-4.2. I did have XCode command line tools installed, but it was looking for /usr/bin/g++-4.2, I had g++ (which was a symbolic link pointing to llvm-g++-4.2). Anyway, I just created a symbolic link to g++ and tried the bundle install again... it worked!
$ cd /usr/bin
$ sudo ln -s g++ g++-4.2
Had the same error, this worked for me:
From console: gem uninstall libv8
In your Gemfile, add the following:
gem 'therubyracer', :platforms => :ruby, :require => 'v8'
gem 'libv8', '~> 3.11.8' # Update version number as needed
From console: bundle install
If you were in the middle of upgrading therubyracer gem, you may want to run bundle update therubyracer after that as well. (Consider specifying a version number)
This was on Mac 10.6 (Snow Leopard).

Resources