Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 976
Totoro Avatar asked Dec 12 '14 16:12

Totoro


2 Answers

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
like image 151
singh1469 Avatar answered Oct 11 '22 18:10

singh1469


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.

like image 33
Totoro Avatar answered Oct 11 '22 19:10

Totoro