如何在远程服务器上安装 sqlite3 gem



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

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

通常,我会在我的本地Mac OSX上安装gem,然后将gem复制到linux服务器,即(来自缓存目录的xxxx.gem文件和来自ruby的gem目录的xxx文件夹)。到目前为止,它一直工作正常。 作为新测试的一部分,我安装了sqlite3 gem并将其.gem文件复制到linux服务器上,并在linux服务器上安装了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 服务器上执行此操作。

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

我遵循了下面帖子中发布的一些建议,但它没有奏效。安装 sqlite3-ruby 时出现问题!SQLe3 gem 安装失败

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

你不能只为OS X编译,然后把这些二进制文件放到Linux上。它们的格式不同。

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

最新更新