首页 > 解决方案 > 如何在没有 root 访问权限的服务器上安装 SQLite3 for Rails

问题描述

我正在尝试在我们的托管服务器上创建一个 Ruby on Rails“Hello World”应用程序,其中没有 root 或sudo可能。

Ruby 是 2.3.3p222 版本,Rails 是 v5.2.4.1。

我曾经rails new testproject创建我的“Hello World”测试。这失败了,bundle install因为我无法在系统中安装 gems

Error "Your user account isn't allowed to install to the system RubyGems"

转到testproject文件夹并输入:

bundle install --path ~/.gem

返回:

This failed with *"An error occurred while installing sqlite3 (1.4.2),
and Bundler cannot continue."*

The reason is an compiler error: *"conftest.c:13:57: error:
‘pthread_create’ undeclared (first use in this function)"* Problem:
The compiler can't find pthread because the *pthread.h* not included.
The only include in the conftest.c is *#include "ruby.h"* and this is
included from the system includes.

我从日志文件中提取了 gcc 命令,更改了包含文件夹的顺序,因此我的本地包含文件夹现在是第一个。我在本地包含中放置了一个虚拟的“ruby.h”,其中包括系统包含文件夹中的“pthread.h”和“ruby.h”。

新的 gcc 命令是:

gcc -o conftest -I/usr/home/admin/include -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -I/usr/include -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-map=/build/ruby2.3-LPgLkQ/ruby2.3-2.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DTAINTING_SUPPORT conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3 -lfalse  -lpthread -lgmp -ldl -lcrypt -lm   -lc

现在出现新错误:

cannot find -lfalse 

当我-lfalse从 gcc 命令中删除时,我不再收到错误。

所以现在我知道“pthread.h”的缺失包含是我的第一个问题。这-lfalse是第二个。但是我该如何解决呢?我怎么知道bundle install要包含 pthread.h?为什么有一个-lfalse

我花了几个小时才达到这一点,但我现在不知道如何继续。

标签: ruby-on-railsrubysqlite3-ruby

解决方案


推荐阅读