【问题标题】:Getting Sinatra running on Ubuntu, Uninitialized constant error让 Sinatra 在 Ubuntu 上运行,未初始化的常量错误
【发布时间】:2012-12-19 16:23:50
【问题描述】:

尝试在 Ubuntu 12.04 上安装 Sinatra。我安装了 RVM,并且我认为我已经安装了所有依赖项(如下所列)。我发现另一个 SO 帖子 (here) 表明我没有安装 libssl-dev,但看起来我安装了。当我跑步时:

sudo gem install sinatra

我明白了:

ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::RemoteFetcher::OpenSSL 

rvm req 安装:

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsq
lite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
autoconf is already the newest version.
automake is already the newest version.
bison is already the newest version.
curl is already the newest version.
git-core is already the newest version.
libncurses5-dev is already the newest version.
libreadline6 is already the newest version.
libtool is already the newest version.
libyaml-dev is already the newest version.
subversion is already the newest version.
zlib1g is already the newest version.
zlib1g-dev is already the newest version.
build-essential is already the newest version.
libc6-dev is already the newest version.
libsqlite3-dev is already the newest version.
libssl-dev is already the newest version.
libxml2-dev is already the newest version.
libxslt1-dev is already the newest version.
openssl is already the newest version.
sqlite3 is already the newest version.
The following packages will be REMOVED:
  libreadline-gplv2-dev
The following NEW packages will be installed:
  libreadline6-dev pkg-config
0 upgraded, 2 newly installed, 1 to remove and 7 not upgraded.
Need to get 40.9 kB/305 kB of archives.
After this operation, 201 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

红宝石版本:

ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

【问题讨论】:

  • 使用rvm时,不需要使用sudo。你试过不安装 gem 吗?

标签: ubuntu gem sinatra


【解决方案1】:

您是否安装了带有 OpenSSL 选项的 RVM?类似的东西

rvm reinstall 1.9.2 --with-openssl-dir=/usr/local

如果您已经在没有 RVM 的情况下在 System 中安装了 Ruby、IRB 或 RubyGems(例如使用 apt-get),有时您会遇到问题。

如果没有,您可能需要考虑使用 OpenSSL 重新安装 RVM。参考RVM Documentation

我还建议在安装 RVM 之前安装以下软件包

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison  \
subversion pkgconfig

【讨论】:

  • 感谢您的提示。不幸的是,我仍然得到一个错误:错误运行'/home/tpowell/.rvm/scripts/fetch ftp.ruby-lang.org/pub/ruby/1.9ruby-1.9.2-p320.tar.bz2',请阅读/home/tpowell/.rvm/log/ ruby-1.9.2-p320/fetch.log 获取 ruby​​ 解释器时出错。停止安装。这对你有用吗?也许我还有其他防火墙问题。
  • 您是否尝试过 ftp 到 ftp.ruby-lang.org/pub/ruby/1.9 并查看它是否被下载?如果不是,则可能是网络/FTP 问题。
【解决方案2】:

这个错误(未初始化的常量 Gem::RemoteFetcher::OpenSSL) 如果 ruby​​gems.org 无法通过 DNS 解析,则可能会发生。 它只是发生在我身上。一旦 DNS 恢复正常,gem install 就开始了 再次工作。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-08
  • 1970-01-01
  • 2011-09-29
相关资源
最近更新 更多