简体   繁体   English

ruby 2.0 rails gem 安装错误“无法加载此类文件 — openssl”

[英]ruby 2.0 rails gem install error “cannot load such file — openssl”

I am using osx 10.8.2 installed ruby 2.0 and.... got this when trying to run "sudo gem install rails"我正在使用osx 10.8.2安装的ruby 2.0并且....在尝试运行“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我之前有 ruby​​ 1.9.x 和 rails 3.2.x 工作正常

You have to install OpenSSL first and recompile ruby again:您必须先安装 OpenSSL 并再次重新编译 ruby​​:

RVM: RVM:

rvm pkg install openssl
rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr

If you're using RVM please follow:如果您使用的是 RVM,请遵循:

$ brew install automake
$ rvm pkg install openssl
$ rvm requirements run
$ rvm reinstall all --force
$ gem install rails

It worked for me.它对我有用。

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.无论您使用 RVM 还是不使用 RVM,只有一次解决方案。

Make sure you have installed OpenSSL first BEFORE installing ruby.确保在安装 ruby​​ 之前先安装了 OpenSSL。

RVM虚拟机

  1. Uninstall rvm卸载 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).不要忘记删除 .bashrc 和/或 .bash_profile(或您使用的任何 shell)中的脚本调用。 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 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.然后安装 RVM,发布 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没有 RVM

First you should find where Ruby is:首先,您应该找到 Ruby 的位置:

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.我希望这对你有帮助。

I fix this error for ruby 2.1.2 as follow.我为 ruby​​ 2.1.2 修复了这个错误,如下所示。

rvm pkg install openssl
rvm reinstall ruby-2.1.2 --with-openssl-dir=$rvm_path/usr

This worked for me which is similar to some of the other answers already posted.这对我有用,类似于已经发布的其他一些答案。

rvm pkg install openssl
rvm reinstall all --force

On OSX, with rbenv and homebrew, the following worked for me:在 OSX 上,使用 rbenv 和自制软件,以下对我有用:

brew install openssl
CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix openssl) rbenv install whatever-ruby-version

When installing ruby 2.0, it is possible that rubygems 2.0 installation did not complete ok, because of openssl.安装 ruby​​ 2.0 时,可能是因为 openssl 导致 ruby​​gems 2.0 安装没有完成。 Make sure you provide a valid path to the openssl config file;确保您提供了 openssl 配置文件的有效路径; you could:你可以:

find . -type f -name "openssl.cnf"

path is usually $HOME/.rvm/usr or $HOME/.rvm/usr/ssl路径通常是 $HOME/.rvm/usr 或 $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.确保 ruby​​gems 安装成功完成。 Might be a better way to fix that path without reinstalling, but this should do it.可能是在不重新安装的情况下修复该路径的更好方法,但这应该可以。

Make sure to check out this page on the rvm site: https://rvm.io/packages/openssl/请务必在 rvm 站点上查看此页面: 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 ...brew install autoconf automake ...

I was able to rvm reinstall 2.0.0 without openssl errors我能够在没有 openssl 错误的情况下rvm reinstall 2.0.0

I had the same problem with the same OS version.我在相同的操作系统版本上遇到了同样的问题。 I use rvm and followed the steps in this command:我使用 rvm 并按照此命令中的步骤操作:

$ 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

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? rvm get head --autolibs=3究竟做了什么? I'm guess it automatically downloads dependencies, but I was hoping for a clear answer.我猜它会自动下载依赖项,但我希望得到一个明确的答案。

I encountered the same openssl error on Fedora when trying to use gem install <package> .尝试使用gem install <package>时,我在 Fedora 上遇到了相同的 openssl 错误。 It seems you need to install additional packages with yum/dnf看来您需要使用 yum/dnf 安装其他软件包

sudo dnf install rubygems rubygem-bundler ruby-devel mariadb-devel

After running the above command, gem install <package> should now work.运行上述命令后, gem install <package>现在应该可以工作了。

just went through the same problem.刚刚经历了同样的问题。 Takes a bit time but, upgrading openssl with需要一点时间,但是,升级 openssl

brew upgrade openssl@1.1

worked for me.为我工作。 Version might be different in the future, type brew install openssl to see which version you can upgrade to.将来版本可能会有所不同,请输入 brew install openssl 以查看您可以升级到哪个版本。 I hope it helps.我希望它有帮助。

If you have libssl 1.1 , your problem may be that these older versions of ruby (2.4 is the cutoff) are only compatible with libssl1.0.如果您有 libssl 1.1 ,您的问题可能是这些旧版本的 ruby​​(2.4 是截止日期)仅与 libssl1.0 兼容。

For debian/ubuntu, please ensure that apt-get install libssl1.0-dev succeeds.对于 debian/ubuntu,请确保apt-get install libssl1.0-dev成功。

如果您使用ruby-install ,它将采用与 rvm 相同的 openssl 参数:

ruby-install ruby-2.0.0-p247 -- --with-openssl-dir=/usr/local/opt/openssl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM