Errors using rspec, missing libraries after installing Homebrew and uninstalling MacPorts - nokogiri

I may have taken one step too far beyond my knowledge. I installed Homebrew and after it continued to give me warnings about having MacPorts installed I uninstalled that. But now my rspec tests don't run.
These are the errors I get:
/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri.rb:13:in `require': dlopen(/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /opt/local/lib/libiconv.2.dylib (LoadError)
Referenced from: /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 - /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
.....
.....
I've installed libiconv through Homebrew, but that didn't fix it. It's complaining about libiconv version numbers. Is this the problem?
What is going on here and what do I need to do?

I got things working again for anyone interested. I removed and re-installed nokogiri gem and everything seems to be working again.

Generally, this problem is caused by being unable to find the right libiconv. Here is how I solve my problem:
Check output of otool -L /usr/lib/libiconv.2.dylib. I got the following output:
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
Then I install libiconv with Homebrew, brew install libiconv, and show where it was installed using brew list libiconv. I got the following output:
/usr/local/Cellar/libiconv/1.14/bin/iconv
/usr/local/Cellar/libiconv/1.14/include/ (3 files)
/usr/local/Cellar/libiconv/1.14/lib/libcharset.1.dylib
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
/usr/local/Cellar/libiconv/1.14/lib/ (3 other files)
/usr/local/Cellar/libiconv/1.14/share/doc/ (6 files)
/usr/local/Cellar/libiconv/1.14/share/man/ (6 files)
the libiconv is installed in /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib. Then I check verion of newly installed libiconv,
otool -L /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib, and I got the following output:
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib:
/usr/local/opt/libiconv/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
The version is correct, and we need to make this library available for Ruby. Creating a symbol link is a quick solution:
sudo ln -s /usr/local/opt/libiconv/lib/libiconv.2.dylib /opt/local/lib/libiconv.2.dylib

I had to re-install libxml-ruby in addition to nokogiri to get things working again.

FWIW, I ran into the same issue and if you are vendorizing your gems, you will have to remove the offending gem from vendor/ruby as a gem uninstall + reinstall is not always efficient. I'm guessing bundler leaves cache remnants of gems and their respective libs even when running a fresh install.

Related

passenger meet Library not loaded error : liblzma.5.dylib

I am trying to running rails with passenger.
I both AWS SDK 1 and 2 gem installed:
gem 'aws-sdk-v1'
gem 'aws-sdk', '~> 2'
when I use AWS sdk to run:
s3 = AWS::S3.new
I meet error:
LoadError: dlopen(/Users/XXXX/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.6.2/lib/nokogiri/nokogiri.bundle, 9):
Library not loaded: /usr/local/lib/liblzma.5.dylib
Referenced from: /Users/XXXX/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.6.2/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later, but liblzma.5.dylib provides version 6.0.0
otool -L shows me that the version is 8.1.0
$ otool -L /usr/local/lib/liblzma.5.dylib
/usr/local/lib/liblzma.5.dylib:
/usr/local/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
It is strange that this error not shows up when I run 'rails s'.
update / uninstall / reinstall xz by brew not helps.
update / uninstall / reinstall gem nokogiri also not helps.
Try to follow this https://github.com/PromyLOPh/pianobar/issues/530#issuecomment-125746641
This is the fix: Cannot get ffmpeg to work after installing from homebrew
Using brew: brew install xz because liblzma is inside xz now
That is not a problem in Passenger, it is a problem in one of your gems. Apparently you installed Nokogiri some time in the past, and back then it was linked to liblzma 5, but some time later you upgraded liblzma to the incompatible version 6. Try uninstalling that gem, then installing it again.
updating gems worked for me
bundle update

Brew doctor shows warnings How to solve it

I am new to OSX while running
brew doctor
shows the following warnings.
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.
Binaries provided by keg-only formulae may override system binaries
with other strange results.
You may wish to `brew unlink` these brews:
openssl
Is there anyway to solve the error without reinstalling OS?
I need to install ruby rails, it shows some errors while running
rails server
command. I think the problem is due to the above warnings.
thanks in advance
#Yahya, I ran into the same problem and managed to fix it after reading this thread: https://github.com/Homebrew/homebrew/issues/29989
I've tried both suggested solutions (reinstalling the essentials package vs copying only the install_name_tool binary) and both worked equally fine (I've given examples for each of them below)
Therefore for Yosemite systems I recommend the fast 'clone&copy' approach, where as for the Mavericks ones - the much slower package replacement.
Yosemite OS
First check the current version of install_name_tool
$ otool -L /usr/bin/install_name_tool
/usr/bin/install_name_tool
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3)
Now clone the Yosemite compatible binary from Github and replace the one in your /usr/bin folder:
$ git clone https://github.com/cinic/install-name-tool
Cloning into 'install-name-tool'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
$ sudo mv /usr/bin/install_name_tool /usr/bin/install_name_tool.orig
$ sudo cp install-name-tool/install_name_tool /usr/bin/
Finally check if the version is updated and if homebrew is fixed:
$ otool -L /usr/bin/install_name_tool
/usr/bin/install_name_tool:
/usr/lib/libxcselect.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
$ brew doctor
Your system is ready to brew.
Finally
$ rm -fr install-name-tool/
$ sudo rm /usr/bin/install_name_tool.orig
Mavericks
Download the Mavericks installer from App store
$ open /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg
$ open /Volumes/OS\ X\ Install\ ESD/Packages/Essentials.pkg
After the package is installed, check if the brew doctor output.
If you are using Homebrew, it will often look for items you have and link them. It looks like it's done that with openssl. You have three options:
Uninstall and reinstall openssl
brew uninstall openssl
brew install openssl
Try upgrading openssl
brew update openssl
Or you can try unlinking openssl (though, only do this if you know where you openssl is)
brew unlink openssl
I also faced the same issue and would get the warning that "/usr/bin/install_name_tool" was outdated.
The problem is that Xcode's install_name_tool has been updated, while the one in the system is outdated.
This can be solved by copying Xcode's install_name_tool to the system.
Use this command :
sudo cp /Applications/Xcode.app/Contents//Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool /usr/bin/install_name_tool
install_name_tool should now be updated.

Inspect or clean up the working tree error when installing Ruby 2.1.3 on Mac OS X 10.9.5

I'm trying to install Ruby 2.1.3 on Mac OS X 10.9.5 using the rbenv install 2.1.3 command. However I get the error message below. I tried every suggestion on stack overflow and elsewhere. Nothing seems to be working. I currently have the original ruby version that came with 10.9.5, Ruby 2.1.3p242. Brew doctor says everything is fine and rbenv is up to date. Thanks so much! Trying to learn Ruby and Ruby on Rails but I can't get passed this stage.
Inspect or clean up the working tree at /var/folders/zg/s1jqg94n0hjggdnmb442n2lc0000gn/T/ruby-build.20141025184549.88303
Results logged to /var/folders/zg/s1jqg94n0hjggdnmb442n2lc0000gn/T/ruby-build.20141025184549.88303.log
Last 10 log lines:
linking shared-object openssl.bundle
installing default openssl libraries
compiling raddrinfo.c
compiling ifaddr.c
installing default socket libraries
compiling init.c
compiling constants.c
linking shared-object socket.bundle
linking shared-object ripper.bundle
make: [build-ext] Error 2
I have a m1 mac and I also got this error installing ruby,
this command worked for me:
export optflags="-Wno-error=implicit-function-declaration";
run this and then try rbenv install again.
Did you try this:
CC=/usr/bin/gcc rbenv install 2.1.3
From this SO answer: Unable to build Ruby 2.1.3 on OSX 10.10 GM 3.0 with rbenv
I had to remove the existing openssl that came with macOS and instead install from brew with brew install openssl.
NOTE: I also had to disable SIP with csrutil disable and then remount root with writable permissions, with sudo mount -uw /.

Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib

I'm getting this error when trying to run rspec in Hartl's tutorial. I googled the error, but it's never for the specific version and the fixes don't actually fix my problem.
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple- darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
I suggest you first uninstall Nokogiri using:
sudo gem uninstall nokogiri
Then install Nokogiri using rubygems:
gem install nokogiri
If that doesn't work, there's an open issue on Nokogiri to support libxml 2.9.0 and later. There's a libxml2-2.9.1 branch that was started in preparation for the next release of libxml2.
Then try pulling from that branch in your Gemfile like this:
gem "nokogiri", github: "sparklemotion/nokogiri", branch: "libxml2-2.9.1"
or install an older version of libxml2.
If that still doesn't work you may also want to try the suggestions here: What to do if libxml2 is being a jerk.
Not sure if it helps anyone, but I could just get nokogiri installed by using system libs
gem install nokogiri -- --use-system-libraries
If you have Homebrew installed, try this. It solves the issue with the "Parsing documentation for nokogiri-1.6.1" hang. This worked for me.
gem uninstall nokogiri libxml-ruby
It'll ask you a series of questions based on how much of it you want to uninstall, answer "yes" or "[y]" to all.
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link --force libxml2
brew install libxslt
brew link --force libxslt
gem install nokogiri --no-rdoc --no-ri
Then, in your project file:
bundle install
Your error message says:
nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib
provides version 10.0.0
This makes me think that your gem actually requires a version of libxml that is newer than your system version. How have you installed libxml2? If you have homebrew installed, you might want to try upgrading it with
brew update
brew upgrade
I was able to install Nokogiri 1.6.0 with Ruby 2.0.0p247 on OS X 10.9, and then require it in IRb. I double checked with Homebrew, and it is actually keg-only. However, Nokogiri seems to install its own version into gems/nokogiri-1.6.0/ports. On my machine, it is under x86_64-apple-darwin13.0.0.
First gem uninstall nokogiri
Second install nokogiri
third restart terminal
be happy
Try the following inside your project directory.
gem uninstall nokogiri
If there are more than one versions installed, a prompt will appear asking which version to remove. use the last option that reads "All versions".
Next, run bundle install inside your project directory. once it finishes installing the needed gems you should be good to go.
In my case, I hit the last option "All versions" as it doesn't hurt my project but it is possible that you might need the other versions based on different projects.
First, check your version of libxml:
otool -L /usr/lib/libxml2.2.dylib
It can return
/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 11.0.0, current version 11.0.0)
or
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
Then you can try reinstalling libxml to upgrade it:
brew uninstall libxml2 libxslt
brew install libxml2 libxslt
After that, try to recompile your package:
make clean
./configure
make
sudo make install
Reinstalling the gem didn't work for me, nor did pulling the particular branch.
It's not ideal, but I found that rolling back to 1.5.9 solved the issue.
Nokogiri generally uses system libraries. So, your ruby has it installed already just make sure that you've run below command before start bundle install.
rvm use ruby-2.2.4 (your current ruby-version)
Sometimes, you also need to run first
/bin/bash --login
rvm use ruby-2.2.4
Note: Only if you're using rvm

Rails, pow and Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib

I didn't work on this rails app for a couple of weeks. Yesterday I got back to it, first opening the .dev URL (i'm using pow) and it gave this error message:
LoadError: dlopen([...]/vendor/bundle/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle, 9): Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib
Referenced from: [...]/vendor/bundle/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle
Reason: image not found - [...]/vendor/bundle/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle
I checked the rbenv install and all seemed fine. I tried to think of recent changes that could lead to this but I can't. I'm pretty sure I'm missing something but my attempts to debug it were futile. I don't know if it's relevant but I recently switched to zsh.
Solution
Uninstall and reinstall sqlite:
~/d/w/r/my-app git:master ❯❯❯ gem uninstall sqlite3
Successfully uninstalled sqlite3-1.3.7
~/d/w/r/my-app git:master ❯❯❯ gem install sqlite3
Fetching: sqlite3-1.3.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.7
1 gem installed
What Happened
When the sqlite3 gem is installed, it builds a native component for talking to sqlite and so it links against the local sqlite3 libraries. This is all handled behind the scenes by gem. When that happens, it specifies the location of the library that it linked against.
Recently (January), the homebrew formula for sqlite became keg-only. Anything that was previously linked against sqlite referenced the homebrew version. You can check this by using otool -L:
~/d/w/r/my-app git:master ❯❯❯ otool -L /path/to/earlier/gem/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle
/path/to/earlier/gem/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle:
/usr/local/lib/libsqlite3.0.8.6.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
Running otool against the new version you can see that it is now linked against the Apple-provided system sqlite libraries:
~/d/w/r/a/new-config git:master ❯❯❯ otool -L /path/to/new/gem/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle
/path/to/new/gem/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle:
/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Resources