【问题标题】:How to install sqlite3 gem on the remote server如何在远程服务器上安装 sqlite3 gem
【发布时间】:2013-09-15 17:24:21
【问题描述】:

我有一个远程 linux 服务器,它没有互联网并且它位于防火墙后面。它没有 gcc 编译器。所以我无法安装或编译。

linux服务器已经安装了ruby 1.9.3的rvm

通常,我会在本地 Mac OSX 上安装 gem,然后将 gem 复制到 linux 服务器,即(来自缓存目录的 xxxx.gem 文件和来自 ruby​​ 的 gem 目录的 xxx 文件夹)。到目前为止,它一直运行良好。作为新测试的一部分,我安装了 sqlite3 gem 并将其 .gem 文件复制到 linux 服务器,并在 linux 服务器上进行了 gem install sqlite。它确实有效并得到了以下错误

gem install sqlite3
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
checking for sqlite3.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local
/ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
    from extconf.rb:34:in `<main>'


Gem files will remain installed in /ngs/app/athenat/.rvm/gems/ruby-1.9.3-p374@11.4.0-1/gems/sqlite3-1.3.8 for inspection.
 Results logged to /ngs/app/athenat/.rvm/gems/ruby-1.9.3-p374@11.4.0-1/gems/sqlite3-1.3.8/ext/sqlite3/gem_make.out

我搜索了一下,发现很多人建议安装 apt-get install libsqlite3-dev。我不能在我的远程 linux 服务器上执行此操作。

任何人都可以建议如何解决这个问题。

我遵循了以下帖子中发布的一些建议,但没有奏效。 Problem installing sqlite3-ruby! sqlite3 gem fails to install

【问题讨论】:

  • 为什么不能安装这些库?你没有sudo 权限吗?
  • 编辑了我的帖子。不,我没有 sudo 权限,但我安装了 rvm。而且我没有找到这个 gem "gem install libsqlite3-dev"
  • 如果您无法运行apt-get,我建议您购买一台可以运行的服务器。否则,您将无能为力。
  • 与服务器管理员交谈,看看他们是否愿意为您安装该软件包。否则,自己从包中提取文件,将它们放在主文件夹中的某个位置,并在安装 gem 时使用可选参数指向目录。

标签: ruby sqlite rubygems


【解决方案1】:

没有编译器将使这种事情几乎不可能发生。

您不能只针对 OS X 进行编译,然后将这些二进制文件放到 Linux 上。它们的格式不同。

您可能能够使用 VMWare Fusion 或 VirtualBox 中的虚拟环境创建与您的 Linux 目标兼容的环境,例如在使用 Vagrant 时,为您的目标操作系统和架构进行编译,以及他们将这些二进制文件运送过来。这通常是最后的手段,因为您必须链接到与远程系统上可用的完全相同的库。正确执行此操作可能需要很长时间。

【讨论】:

    猜你喜欢
    • 2016-11-17
    • 2011-05-30
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多