Install therubyracer gem on OSX 10.11 El Capitan - bundler

bundle install fails with Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling
gem install therubyracer -v '0.12.1' fails with errors which appear to relate to compilation
Prior to this, libv8 gem was having problems but that is now installed thanks to following SO posts.
Guides for fixing rubyracer for Mavericks seem to not work, due to changes in El Capitan?
ln: /usr/bin/cpp: Operation not permitted

Install xcode through app store
Install 'command line tools' for xcode (xcode-select --install)
If using rbenv, after installing ruby you needed rbenv rehash
Assuming you have run gem install bundler and got errors, remove your mess:
gem uninstall libv8
gem uninstall therubyracer
brew rm v8
Install gcc4.2
brew tap homebrew/dupes
brew install apple-gcc42
Install v8
brew tap homebrew/versions
brew install v8-315
brew link --force v8-315
Install gems
gem install libv8 -- --with-system-v8
gem install therubyracer
if you get dyld: lazy symbol binding failed: Symbol not found, #rpbaltazar suggests an alternative:
bundle config --local build.libv8 --with-cxx=/usr/local/bin/g++-4.2
bundle install

I still had issues with #xxjjnn's answer. The following answer from github resolved it. My current setup: El Capitan 10.11.4 and Xcode 7.3.
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install

The answer provided on therubyracer Github page worked for me:
brew tap homebrew/versions
brew install v8-315
brew link --force v8-315
gem install libv8 -- --with-system-v8
gem install therubyracer

I updated the gem therubyracer to 0.12.2, then I runned this commands in the rails repository:
$ brew install v8-315
$ bundle config --local build.libv8 --with-system-v8
You are replacing the current local value of build.libv8, which is currently nil
$ bundle config --local build.therubyracer --with-v8-dir=$(brew --prefix v8-315)
You are replacing the current local value of build.therubyracer, which is currently nil
and finally
bundle install

I know this question is specifically about installing therubyracer -v '0.12.1', but the solution really is to upgrade to '0.12.2'.
I've struggled with this on a few projects and always forget that. Then eventually I remember and it all works.
Be sure to clean out anything you've added to bundle config once you don’t need it with bundle config --delete build.libv8.
Here’s the thread on the gem repo about this: https://github.com/cowboyd/therubyracer/issues/398#issuecomment-238161167

(Posting as a comment for readability purposes, but this should be an add-on to the original accepted answer)
After running the accepted answer, I was facing the error described in the comments.
The solution I found helpful for me was running the following
gem uninstall libv8
gem uninstall therubyracer
bundle config --local build.libv8 --with-cxx=/usr/local/bin/g++-4.2
bundle install
Please note that the initial steps of the accepted answer are necessary, namely installing the compiler.

Actually, apple-gcc42 is removed from brew:
apple-gcc42 was deleted from homebrew/core in commit bcba321ea:
Instead, I've installed gcc#4.9
So, following xxjjnn answer, instead of 5 just run:
brew install gcc#4.9

First try to delete your Gemfile.lock and run bundle install again. Gemfile.lock will be created again.
This will work for most cases on El Capitan.
Without that it will just install the same versions mentioned in Gemfile.lock. If you delete this file, bundle install will fetch newest versions of your gems.

If none of the above works for you, follow this guys advice. Uninstalling everything related and upgrading gcc fixed it for me.
Gem install therubyracer -v '0.11.4'?

If you can switch to mini racer, installing it or updating it worked for me similar to this post
How to fix libv8 bad version error
TL;DR bundle update mini_racer

Related

Error occured while installing unf_ext (0.0.7.4), and Bundler cannot continue

My ultimate goal is to get this to work in an Ubuntu 14.04 Docker container: https://github.com/byalextran/autoluv
When I run
m1#9bdc67007b49:~/autoluv$ bundle install --deployment
It says:
Fetching unf_ext 0.0.7.4
Installing unf_ext 0.0.7.4 with native extensions
Errno::EACCES: Permission denied # rb_sysopen - /home/m1/autoluv/vendor/bundle/ruby/2.4.0/gems/unf_ext-0.0.7.4/.document
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4' --source 'https://rubygems.org/'` succeeds before bundling.
But when I run
sudo gem install unf_ext -v '0.0.7.4' --source 'https://rubygems.org/'
unf_ext-0.0.7.4 installs fine?
Building native extensions. This could take a while...
Successfully installed unf_ext-0.0.7.4
1 gem installed
Installing ri documentation for unf_ext-0.0.7.4...
Installing RDoc documentation for unf_ext-0.0.7.4...
I cannot figure out the next step. I've tried installing ruby-dev and gcc, but neither has helped move this along :(
Any and all help is much appreciated!
I had this same problem and the reason was that I did not installed all the dependencies that bundler needs to run
just try to:
sudo apt-get install build-essential
then run again
gem install bundler
and lastly
bundler
There is a difference between running commands with sudo and without. You can get more info about this command here https://kb.iu.edu/d/amyi.
Errno::EACCES usually happens when bunder has no access to a needed folder or it doesn't exist.
Try to gem install unf_ext -v '0.0.7.4' --source 'https://rubygems.org/' without sudo.
I had same issue on Fedora.
I simply had to install the gcc-c++ package.
I solved this error on Debian 10 buster in my ChromeOS Linux container by installing rbenv: sudo aptitude install rbenv or sudo apt install rbenv.
Aptitude package manager seems to be better at resolving dependencies and allowing me to install newer packages more easily than the default apt so I thought it was worth mentioning.
Solved it after using following commands for Xcode 13, BigSur :
softwareupdate --install a
sudo port upgrade outdated
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget
brew install build-essentials
bundler install
If you are an iOS developer who is getting this error, this might be related to your Xcode command line tools selection.
Just run the following command with the path of the Xcode that you are using currently.
sudo xcode-select --switch /Applications/Xcode.app
You need to use the latest version of Ruby.
If you are using MacOS, system Ruby is old and outdated. you can not update the system Ruby, but you can install another version of Ruby and make it default global using rbenv ruby version manager tool.
finally you can install any ruby packages you like.

How to install Nokogiri on Mac OS Sierra 10.12

I'm having troubles installing Nokogiri (1.6.8.1) on Mac OS Sierra 10.12.
I tried using brew install libxml2 libxslt and then referencing the install directories using command line options but it didn't help.
Open Xcode and, from the menu XCode -> Preferences update your Command Line Tools (Xcode 8.0).
Then do:
bundle config build.nokogiri --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
bundle install
or just:
gem install nokogiri -v 1.6.8.1 -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
The more simple solution is to execute:
xcode-select --install
gem install nokogiri
Update
For Mojave I'm using gem install nokogiri -v '1.6.6.2' -- --use-system-libraries
Try install libxml2 first with Homebrew.
brew install libxml2
Then if installing with bundle
bundle config build.nokogiri --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
bundle install
If installing directly with gem
gem install nokogiri -- --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
This might be a duplicate of gem install nokogiri -v '1.6.8.1' fails ... latest accepted answer there was to do:
brew unlink xz; bundle install; brew link xz
Re-linking xz might not be necessary ... if for example you only have that dependency because of the_silver_searcher (which links directly against the non-symlinked library).
gem update --system
xcode-select --install
brew unlink xz
gem install nokogiri -v '1.6.8.1'
brew link xz
If the above steps fail to fix the issue, what has also worked for me is running brew doctor and cleaning up any unbrewed header files.
Similar to yuяi's answer and from Nokogiri's help:
brew unlink xz
gem install nokogiri
brew link xz
http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x
This worked for 1.7.0.1
For Middleman
gem install nokogiri -v '1.8.2' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2/
If you have earlier installed nokogiri using bundler with bundle config build.nokogiri --use-system-libraries this setting will still be there. If you then meanwhile have solved your Xcode setup (as suggested as the primary method of installation in the nokogiri installation) then you might wanna try removing that fra from bundler bundle config --delete build.nokogiri and try again doing bundle install.
First install XCode from the app store
then run
bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries
then run
bundle install
this should work

Error for macos sierra install cocoapods

When i install mac os sierra, trying install cocoapods, but appear error:
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
but i already installed openssl and ruby,i really don't know is why,does anyone know?
Install Cocoapods by below 3 commands
sudo gem update --system -n/usr/local/bin
sudo gem install -n /usr/local/bin cocoapods
pod setup

OpenSSL error installing ruby 2.0.0-p195 on Mac with rbenv

I'm trying to install Ruby 2.0.0-p195 using rbenv on a Mac (Mountain Lion) and got this error.
BUILD FAILED
Inspect or clean up the working tree at /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669
Results logged to /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669.log
Last 10 log lines:
installing default gems: /Users/me/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
bigdecimal 1.2.0
io-console 0.4.2
json 1.7.7
minitest 4.3.2
psych 2.0.0
rake 0.9.6
rdoc 4.0.0
test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?
When I ran brew install openssl it said
Warning: openssl-1.0.1e already installed
Following a solution on this thread https://github.com/sstephenson/ruby-build/issues/305 I tried to install latest stable this way and got the same error
env CFLAGS='-g -O2' RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p195
Any ideas?
Try adding OpenSSL to the config options using the --with-openssl-dir option:
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195
If you're using Homebrew, you'll need to install OpenSSL before running the above by running:
$ brew install openssl
UPDATE (see #JarkkoLaine 's comment below):
Just for the record, you should not need to use the config opts
anymore with ruby-build and homebrew. However, I had to reinstall
openssl with homebrew to make it work: brew uninstall openssl; brew
upgrade; brew install openssl; rbenv install 2.0.0-p247. See this for
more info.
I fixed this by executing:
brew link openssl --force
Mac OSX 10.9.4
Upgrading to the latest version of ruby-build fixed the problem for me:
Like the OP, I got
BUILD FAILED
Inspect or clean up the working tree at /Users/me/.rbenv/sources/2.0.0-p247
Results logged to /var/folders/3x/y_8y8vr53ws_kxj97km79q5h0000gn/T/ruby-build.20130704172404.3106.log
Last 10 log lines:
installing default gems: /Users/me/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
bigdecimal 1.2.0
io-console 0.4.2
json 1.7.7
minitest 4.3.2
psych 2.0.0
rake 0.9.6
rdoc 4.0.0
test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?
but installing the latest version of ruby-build, via
# Don't forget brew doctor and brew update if required
brew upgrade ruby-build
fixed it.
Ruby-build had some changes between when the OP asked and now, which would explain why it worked for me, but not for the OP using the latest stable version of ruby-build.
For those who have problems installing openssl.
I had this error on my Mac 10.8.4
brew install openssl
created directory `/usr/local/Cellar/openssl/1.0.1e/include/openssl'
make: *** [install_sw] Error 13
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
These open issues may also help:
https://github.com/mxcl/homebrew/pull/19429
Create a directory if it does not exist
sudo mkdir /usr/local/etc/openssl
Change the rights. Replace and with your name and group (e.g. serge:admin)
sudo chown -R <username>:<group> /usr/local/etc/openssl/
Repeat openssl installation
brew install openssl
Install curl-ca-bundle
brew install curl-ca-bundle
install ruby
CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195
Bingo
Solution using ruby-install:
After uninstalling and installing openssl a couple of times (probably unnecessary) I successfully tried this:
ruby-install ruby 2.1.3 -- --with-openssl-dir=`brew --prefix openssl`
The missing library is libssl*-dev* / openssl*-dev*, depending your distribution.
This issue came up again for me with Mac OS 10.9.5
Mac upgraded the command-line tools and that upgraded openssl, which broken rbenv.
I tried all of these solutions, but none of them worked. Everything was up-to-date, but I couldn't install any new gems or build rubies.
My solution was to:
Remove the ruby version (for me it was 2.1.1)
Brew uninstall ruby-build and rbenv
Brew Re-install rbenv and ruby-build
Hope this helps you if you encounter it too!

Failed to build gem native extension when install RedCloth-4.2.9 install Linux

I want to install Octopress in my computer.
I try to do it like
Octopress document.
When I run
bundle install
I got error message
An error occured while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
So, I run
sudo gem install RedCloth -v '4.2.9'
then, I got a error message again:
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
I hadn't learn any knowledge about ruby.
My ubuntu 12.04 solution is install the ruby1.9.1-full version, that can resolve this issue.
sudo apt-get install ruby1.9.1-full
you can execute command:
sudo update-alternatives --config ruby
to select the altiernative ruby which you have installed.
and then, execute below commands to finish the octopress deploy:
git clone https://github.com/erizhang/octopress.git octopress
cd octopress/
sudo gem install bundler
sudo gem install RedCloth -v '4.2.9'
bundle install
rake install
below commands you can find from octopress deploy guideline page:
rake setup_github_pages
sudo rake setup_github_pages
sudo rake generate
sudo rake deploy
Hope it's helpful for you, thanks
I was installing Octopress too and got the same problem as yours. After checking the mkmf.log file I figured out that gcc-4.2 had not been found. I Even installed xcode with the command line tools. It worked when I made a symlink like this:
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
$ bundle install
I fixed this issue by running
sudo apt-get install ruby-dev
as described in this blog post.
You've probably upgraded to Mountain Lion and have not rebuilt your ruby-1.9.2 install yet with the new development packages.
rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install
If you don't have the Mountain Lion dev packages installed correctly, use the ThoughtBot instructions.
For Ubuntu 14.04 simply do this:
sudo apt-get install ruby1.9.3
Should work for 13.10 and 13.04 too. (Not tested)
it apears you are not using rvm for managing your ruby installation. I think best would be to try rvm, here's a very good guide, you can stop without installing rails: ruby with rvm
Then simply
$gem install RedCloth
Unmanaged ruby gems are a pain, I try to avoid them.
None of the answers worked on my Ubuntu 14.04.1 LTS. Upgrade to ruby 2.0 fixed the problem for me:
sudo apt-get install ruby2.0 ruby2.0-dev
sudo ln -s /usr/bin/ruby2.0 /usr/bin/ruby
sudo ln -s /usr/bin/gem2.0 /usr/bin/gem
sudo gem install bundler
Make sure you also have the build-essential package installed. You can check using
dpkg -l | grep build-essential
or simply install it without checking
sudo apt-get install build-essential
For me on Ubuntu 14.04.1 LTS, after making sure build-essential is installed, the bundle install command works/builds fine also with Ruby 1.9.3.

Resources