ruby on rails openssl

在尝试使用Ruby 1.9.3-p362和Rails 3.2.11创建新项目时,遇到由于缺少OpenSSL支持导致的错误。通过将Gemfile中的源从'https'更改为'http',或者重新编译Ruby并启用OpenSSL支持,可以解决此问题。在修改Gemfile后,项目成功创建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ruby使用的是1.9.3-p362 自己编译安装的:configure && make && make install

Rails使用的是3.2.11

在创建新项目时报错:

$:rails new demo

         run  bundle install
Fetching gem metadata from https://rubygems.org/.
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL
using RVM are available at rvm.io/packages/openssl.

修改demo/Gemfile第一行后重新创建项目,项目创建成功

source 'https://rubygems.org' --> source 'https://rubygems.org'


$:cd demo

$:rails server
`require’: cannot load such file — openssl (LoadError)”
处理办法:

先安装libssl-dev:

1 sudo apt-get install libssl-dev

然后编译出一个共享库来安装进去就可以了,方法如下:
进入ruby源码目录下,然后

1 cd ext/openssl

之后编译出.so文件安装:

1 ruby extconf.rb
2 make
3 sudo make install

不需要重新编译ruby,直接可用。重新创建demo项目,成功;启动服务器,成功。访问http 3000端口,成功。


参考:http://lunae.cc/solve-can-not-load-such-file-openssl-error



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值