可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am using osx 10.8.2 installed ruby 2.0 and.... got this when trying to run "sudo gem install rails"
$ sudo gem install rails ERROR: Loading command: install (LoadError) cannot load such file -- openssl ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass
I had ruby 1.9.x and rails 3.2.x working alright before
回答1:
You have to install OpenSSL first and recompile ruby again:
RVM:
rvm pkg install openssl rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
回答2:
If you're using RVM please follow:
$ brew install automake $ rvm pkg install openssl $ rvm requirements run $ rvm reinstall all --force $ gem install rails
It worked for me.
回答3:
I had very bad time with this ERROR. Finally i done with it. There is only Once solution either you are with RVM or without RVM.
Make sure you have installed OpenSSL first BEFORE installing ruby.
RVM
Uninstall rvm
rvm implode
or
rm -rf ~/.rvm
Don’t forget to remove the script calls in your .bashrc and/or .bash_profile (or whatever shell you’re using). sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs
Then install RVM, post ruby.
OR
rvm pkg install openssl rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
WITHOUT RVM
First you should find where Ruby is:
whereis ruby
will list all the places where it exists on your system, then you can remove all them explicitly. Or you can use something like this:
rm -rf /usr/local/lib/ruby rm -rf /usr/lib/ruby rm -f /usr/local/bin/ruby rm -f /usr/bin/ruby rm -f /usr/local/bin/irb rm -f /usr/bin/irb rm -f /usr/local/bin/gem rm -f /usr/bin/gem
THEN
sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs apt-get -y update apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev cd /tmp wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz tar -xvzf ruby-2.0.0-p247.tar.gz cd ruby-2.0.0-p247/ ./configure --prefix=/usr/local make make install
I hope this help you.
回答4:
On OSX, with rbenv and homebrew, the following worked for me:
brew install openssl CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix openssl) rbenv install whatever-ruby-version
回答5:
When installing ruby 2.0, it is possible that rubygems 2.0 installation did not complete ok, because of openssl. Make sure you provide a valid path to the openssl config file; you could:
find . -type f -name "openssl.cnf"
path is usually $HOME/.rvm/usr or $HOME/.rvm/usr/ssl
Then
[sudo] rvm reinstall ruby-2.0.0-p0 --with-openssl-dir=[openssl.cnf path] --verify-downloads 1
Make sure rubygems installation complete successfully. Might be a better way to fix that path without reinstalling, but this should do it.
回答6:
Make sure to check out this page on the rvm site: https://rvm.io/packages/openssl/
Running
rvm requirements run
gave me:
Missing required packages: autoconf, automake, libtool, pkg-config, apple-gcc42, readline, libxml2, libxslt, libksba, openssl, sqlite
after brew install autoconf automake ...
I was able to rvm reinstall 2.0.0
without openssl errors
回答7:
I had the same problem with the same OS version. I use rvm and followed the steps in this command:
$ rvm requirements
Following those instructions, I ran:
$ brew update $ brew tap homebrew/dupes $ brew install bash curl git $ brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba
回答8:
This worked for me which is similar to some of the other answers already posted.
rvm pkg install openssl rvm reinstall all --force
回答9:
I had the same problem earlier, tried all of the snippets about and none of them worked out. After looking around for a bit the following worked for me:
$ rvm remove 2.0.0 # get rid of unsuccessful installation $ rvm get head --autolibs=3 # get the latest RVM and build required libs $ rvm requirements # just in case, install all other required stuff $ rvm install ruby-2.0.0 $ rvm --default use ruby-2.0.0
What does rvm get head --autolibs=3
do exactly? I'm guess it automatically downloads dependencies, but I was hoping for a clear answer.
回答10:
I encountered the same openssl error on Fedora when trying to use gem install
. It seems you need to install additional packages with yum/dnf
sudo dnf install rubygems rubygem-bundler ruby-devel mariadb-devel
After running the above command, gem install
should now work.