Anyone having issues installing bson_ext gem in OSX lion - ruby-on-rails-3

OSX Lion, Xcode 4.2, GCC 4.2
I get the following error installing bson_ext 1.4.1
Building native extensions. This could take a while...
ERROR: Error installing bson_ext:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for asprintf()... *** 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.

I just ran into this. You should look in the mkmf.log file. Chances are, it's looking for GCC in the wrong place. I had to:
cd /usr/bin
sudo ln -s i686-apple-darwin11-llvm-gcc-4.2 i686-apple-darwin11-gcc-4.2.1
And all was well.

The accepted answer did not work for me. But this did.
I am using:
OS X 10.8.2
Xcode 4.6 (with command line tools)
bson_ext 1.8.2
cd /usr/bin && sudo ln -s ./gcc gcc-4.2
$ gem install bson_ext -v 1.8.2
Building native extensions. This could take a while...
Successfully installed bson_ext-1.8.2
1 gem installed
Installing ri documentation for bson_ext-1.8.2...
Installing RDoc documentation for bson_ext-1.8.2...

So re-installing OSX lion fixed the problem. I guess uninstalling xcode 4.1 in the first place messed up my developer tools installation.
Thanks for the help.

I don't use XCode for anything but the developer tool binaries so I just uninstalled XCode:
sudo /Developer/Library/uninstall-devtools –mode=all
And then installed this:
https://github.com/kennethreitz/osx-gcc-installer
Fixed the problem right up and I saved some HD space to boot.

Related

YAML safe loading is not available

When I want to install compass with gem install compass, I occurred with this error:
YAML safe loading is not available.
Please upgrade psych to a version that supports safe loading (>= 2.0).
what The cause of this error and how can I solve the problem?
It sounds like the psych gem needs to be updated. Try running gem install psych and then gem update psych.
Suggested by looking at the psych readme file here: https://github.com/ruby/psych/blob/master/README.md
EDIT: you might also have to update your version of ruby. This depends on how you have installed ruby, but #ewerx has one suggestion in their answer.
To resolve this I first upgraded Ruby from 2.0.x to 2.4.2 (https://gorails.com/setup/osx/10.12-sierra):
rbenv install 2.4.2;
rbenv global 2.4.2
Then updated gems:
sudo gem update --system;
gem update
It may be sufficient to just update gems.
The following part of the post on https://gorails.com/setup/osx/10.12-sierra solved my issue.
We will be setting up a Ruby on Rails development environment on macOS 10.12 Sierra.
Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.
Installing Homebrew
First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source.
Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes.
Open Terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
Choose the version of Ruby you want to install:
Now that we have Homebrew installed, we can use it to install Ruby.
We're going to use rbenv to install and manage our Ruby versions.
To do this, run the following commands in your Terminal:
brew install rbenv ruby-build
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Install Ruby
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v

Unable to install therubyracer on clean install of Yosemite and clean version of ruby

There are many people with similar issues and I've been one of them in the past on other machines and none of the solutions out there appear to work -- I also appear to have different error than others who have similar problems:
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -r ./siteconf20150412-25981-y7cvt6.rb extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
In file included from accessor.cc:1:
In file included from ./rr.h:6:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:604:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found
#include <__debug>
^
1 error generated.
make: *** [accessor.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/ecnalyr/.rvm/gems/ruby-2.0.0-p353#canopy/gems/therubyracer-0.12.2 for inspection.
Results logged to /Users/ecnalyr/.rvm/gems/ruby-2.0.0-p353#canopy/extensions/x86_64-darwin-14/2.0.0/therubyracer-0.12.2/gem_make.out
When running:
gem install therubyracer -v '0.12.2'
or simply
bundle install
with therubyracer included in my gemfile.
I'm running Yosemite 10.10.3, Ruby 2.0.0-p353, I have uninstalled everything and tried the gem install libv8 -- --with-system-v8 solution that comes up frequently with these kind of problems, but have found no resolution.
Creating a temporary file '__debug' solved this issue for me.
Run this command in terminal:
echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null
I was able to solve this by re-installing Command Line Tools for XCode 6.2 (instead of those for XCode 6.3).
There's more discussion in Stack Overflow 29529455.

Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0

The command rails server throws this error.
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load
such file -- mysql2/2.0/mysql2 (LoadError)
I use Ruby 2.0.0 from RubyInstaller on Windows XP box.
I figured out what is the problem but I don't know how to solve it. The problem is that there is no any 2.0/ directory in the mysql2-0.3.11-x86-mingw32 gem. This is the gem that rails installs as its dependency from Gemfile:
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
This is what is in that mysql2.rb file:
# C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\mysql2.rb
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql2/#{$1}/mysql2" # <<-- this is that #2 line that throws an error
It is obvious that it takes the current Ruby version number and uses it as the path segment to reach some mysql2 file. In fact it is mysql2.so file. As I use Ruby 2.0.0 the path segment is 2.0:
mysql2/2.0/mysql2
Ok, now lets see how that directory of mysql2-0.3.11-x86-mingw32 gem looks like:
dir: C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\
No any 2.0/ directory.
I know the issue about libmysql.dll. I have it in my C:\Ruby200\bin. It doesn't help.
I read this answer https://stackoverflow.com/a/5368767/1114926 from the creator of RubyInstaller. I tried but it didn't help. It works for Ruby 1.9.3 because there is 1.9/ directory. But it doesn't work for Ruby 2.0.0.
How to solve it?
UPD 1:
Thank you for your answer. I've tried. Unfortunately I have ERROR: Failed to build gem native extension. error:
C:\>gem install mysql2 --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** 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
--without-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=C:/Ruby200/bin/ruby
C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (Runtim
eError)
You have to install development tools first.
... other code follows here...
It says:
You have to install development tools first.
But I have full DevKit installed, RubyInstaller installs it. Can't understand what else does it need.
I've already posted an issue to mysql2 GitHub page https://github.com/brianmario/mysql2/issues/364. No answers yet.
Had the absolutely same issue on Windows 7 x64 with Ruby 2.0.0 and DevKit 4.7.
The following steps helped me.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
uninstall mysql2-0.3.11-x86-mingw32, gems compiled before Ruby200 won't work. You have to compile it yourself.
If you run gem uninstall mysql2 and there is a non compiled version listed then just uninstall mysql2-0.3.11-x86-mingw32 - the compiled version else...
Installation
gem install mysql2 --platform=ruby. that would work.
Follow this guide on installing devkit http://rubyonwindowsguides.github.com/book/ch02-04.html.
Then try again.
Exactly the same behavior when I try to install Redmine on windows XP
when I try to do the "rake generate_secret_token", I got "cannot load
such file -- mysql2/2.0/mysql2 (LoadError)"
and when I try to re build mysql2 using --platform=ruby, I got the
same message as you green.
for the moment, I am stucked there ... but if anybody has anything to allow me to move forward, it will be very welcome.
I will keep informed as well
antoine
I almost done the same what #odiszapc described. Uninstall old gem, download mysql-connector-c-noinstall, unzip, but finally I used this command to build native gem:
gem install mysql2 --platform=ruby -- --with-opt-dir=/c/connector-6.0.2
(If you use git-bash then you can use unix style directory syntax.)
Copy paste from that link: https://github.com/brianmario/mysql2/issues/359. It worked for me.
If after installing the gem, you get an error:
"The specified module could not be found.
C:/Devel/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so"
That can be fixed by copying libmysql.dll to Ruby's bin folder.

Trouble installing json gem on mountain lion

I tried running bundle install and it stopped on the json gem. So I tried running running sudo gem install json 1.7.3 which is the version that it crashed on it it gave the following:
unknown109addaae0a6:introhive Jody$ sudo gem install json
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.3 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
Then if I look at the gem_make.out file it looks like this:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
I've tried making sure command line tools were installed, but I'm at a bit of a loss on how to get by this one.
Any help would be appreciated. Thanks
I was having a similar problem installing JSON 1.7.4 except I'm using RVM. Anyhow, what I did to remedy my problem was install Xcode 4.4 from developer.apple.com and once that was installed I had to install Xcode's command line tools. You can install the command line tools by launching Xcode then clicking Xcode > Preferences > Downloads and click install next to command line tools.
I eventually had to go to ruby 1.9.2 in order to make it work.
Upgrading from 1.9.3-p125 to 1.9.3-p194 did it for me.
It looks like Apple updated the Developer tools this month (August 2012)
I was hitting this problem and I just downloaded the latest Dev tools from https://developer.apple.com/downloads/index.action and now everything works.
I too had the same error message when trying to install Ruby On Rails on a Mountain Lion 10.8.2 system with Xcode 4.6.
A ruby version 1.8.6 is part of the normal OSX installation. After installation the command line tools in Xcode; as posted by Dwight Scott in this thread:
*launching Xcode then clicking Xcode > Preferences > Downloads and click install next to command line tools.*
The solution worked:
*<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed json-1.7.6
Successfully installed rdoc-3.12.1
Successfully installed railties-3.2.11
Successfully installed bundler-1.2.3
Successfully installed rails-3.2.11
5 gems installed*
Thanks Dwight

Problem w/ Paperclip, MacPorts, ImageMagick & Snow Leopard

I'm attempting to use ImageMagick along w/ Paperclip to handle the images on my rails app. The problem is whenever I try to upload an image I get the following in the terminal:
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/go/goZ833AaFaqyvv5RnLqQmE+++TM/-Tmp-/stream20110107-6356-1xfs9j1-0.jpg is not recognized by the 'identify' command.>
I have added the following to my environments/development.rb file:
Paperclip.options[:command_path] = "/usr/local/bin"
If I try to interact w/ ImageMagick in the terminal by using "convert" or something similar I get:
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 10.0.0 or later, but libltdl.7.dylib provides version 9.0.0
Trace/BPT trap
I've already tried updating everything w/ port but the problem still persists. Does anyone have any ideas or suggestions?
I strongly suggest giving up macports and using homebrew. I've never once missed macports since changing. Homebrew uses git and ruby (tools you should be familiar with), and all the installation 'formulae' are very easy to follow. Here's the imagemagick one:
https://github.com/mxcl/homebrew/blob/master/Library/Formula/imagemagick.rb
Note that it spends a lot of time working around 'gotchas'. To install, you would just run:
brew install imagemagick
You appear have an older version of libtool. Running
"otool -LD /opt/local/lib/libltdl.7.dylib" should show you that. I had a similar issue, and solved it by uninstalling ImageMagick completely, then running
sudo port selfupdate
sudo port upgrade outdated (which upgraded libtool, btw)
and then reinstalling ImageMagick.
Just had the same issue, easily fixed it.
You may want to uninstall / reinstall the rmagick gem:
gem uninstall rmagick
gem install rmagick
Worked like a charm for me