Rails rails new test_app 时出现以下错误!求解啊!!!!

hangzai · 2011年11月28日 · 最后由 mike 回复于 2012年04月28日 · 5050 次阅读

求解啊!

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/bin/ruby extconf.rb 
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... no
checking for sqlite3_backup_init()... no
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -DHAVE_RB_PROC_ARITY -DHAVE_SQLITE3_COLUMN_DATABASE_NAME -DHAVE_SQLITE3_ENABLE_LOAD_EXTENSION -DHAVE_SQLITE3_LOAD_EXTENSION  -D_FILE_OFFSET_BITS=64  -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -o database.o -c database.c
database.c: In function ‘initialize’:
database.c:47: error: ‘SQLITE_OPEN_READWRITE’ undeclared (first use in this function)
database.c:47: error: (Each undeclared identifier is reported only once
database.c:47: error: for each function it appears in.)
database.c:47: error: ‘SQLITE_OPEN_CREATE’ undeclared (first use in this function)
database.c:72: error: ‘SQLITE_OPEN_READONLY’ undeclared (first use in this function)
database.c: In function ‘set_sqlite3_func_result’:
database.c:278: error: ‘sqlite3_int64’ undeclared (first use in this function)
make: *** [database.o] Error 1


Gem files will remain installed in /home/deployer/.bundler/tmp/24638/gems/sqlite3-1.3.4 for inspection.
Results logged to /home/deployer/.bundler/tmp/24638/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
An error occured while installing sqlite3 (1.3.4), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.4'` succeeds before bundling.
$ sudo apt-get install libsqlite3-dev

#1 楼 @huacnlee deployer@localhost:~$ sudo apt-get install libsql3-dev 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 Reading state information... 完成 E: 无法找到软件包 libsql3-dev

#2 楼 @hangzai 写错了,更改了一下,看上面的回复

#3 楼 @huacnlee 好的~ 多谢!

#3 楼 @huacnlee 为什么无法启动啊,,我是真真的装了一天一夜了!!!``deployer@localhost:~/sites/test_app$ unicorn -c config/unicorn.rb -D /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:88:inblock in reload': directory for pid=/home/deployer/sites/test_app/tmp/pids/unicorn.pid not writable (ArgumentError) from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:in each' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:inreload' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:65:in initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:innew' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:in initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/bin/unicorn:121:innew' from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/bin/unicorn:121:in <top (required)>' from /usr/local/bin/unicorn:19:inload' from /usr/local/bin/unicorn:19:in `

' master failed to start, check stderr log for details

#6 楼 @hangzai 重复@只会让人厌烦

directory for pid=/home/deployer/sites/test_app/tmp/pids/unicorn.pid not writable

检查一下这个文件或路径的权限,当前用户能访问不?(比如你之前用 root 启动,导致这个文件是 root 所有)

#7 楼 @Rei 哦~不好意思。。不太懂规矩。下次不会了 启用了 root 权限 还是不行的。

root@localhost:~/sites/test_app# unicorn -c config/unicorn.rb -D
/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:88:in `block in reload': directory for pid=/home/deployer/sites/test_app/tmp/pids/unicorn.pid not writable (ArgumentError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:in `each'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:84:in `reload'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/configurator.rb:65:in `initialize'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:in `new'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:102:in `initialize'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/bin/unicorn:121:in `new'
    from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.1.1/bin/unicorn:121:in `<top (required)>'
    from /usr/local/bin/unicorn:19:in `load'
    from /usr/local/bin/unicorn:19:in `<main>'
master failed to start, check stderr log for details

#8 楼 @hangzai

ls -ld /tmp/pids/
ls -l /tmp/pids/unicorn.pid

执行看看结果

deployer@localhost:~$ ls -ld /tmp/pids/
ls: cannot access /tmp/pids/: No such file or directory
deployer@localhost:~$ ls -l /tmp/pids/unicorn.pid
ls: cannot access /tmp/pids/unicorn.pid: No such file or directory
deployer@localhost:~$ sudo -s 
[sudo] password for deployer: 
root@localhost:~# ls -ld /tmp/pids/
ls: cannot access /tmp/pids/: No such file or directory
root@localhost:~# ls -l /tmp/pids/unicorn.pid
ls: cannot access /tmp/pids/unicorn.pid: No such file or directory
  1. 最好别用 root 用户搞;
  2. 没次出现错误提示的时候要注意看提示信息,里面多少会有描述的,更具描述去找问题;
  3. @10楼 的回复来看,基本的 Linux 操作你都没搞懂啊,明显如果 /tmp/pids 没东西,就算是用 root 帐户去 ls /tmp/pids 也是同样的结果啊!

#9 楼 @Rei 写错了,你应该用这样发上来看看

deployer@localhost:~$ ls -lh ~/sites/test_app/tmp
deployer@localhost:~$ ls -lh ~/sites/test_app/tmp/pids/unicorn.pid

自己新建一个 tmp/pids 文件夹,然后执行,不用 root

#11 楼 @huacnlee 不好意思 小弟基础浅薄 想在 VPS 搭建个环境 ```deployer@localhost:~$ ls -lh ~/sites/test_app/tmp total 4.0K drwxr-xr-x 3 deployer staff 4.0K 2011-11-28 16:08 cache deployer@localhost:~$ ls -lh ~/sites/test_app/tmp/pids/unicorn.pid ls: cannot access /home/deployer/sites/test_app/tmp/pids/unicorn.pid: No such file or directory

#13 楼 @hangzai 额!明显你这种处理问题的方式不靠谱啊,这样是没人愿意理你的哦! 这些问题都是很基础的,其实你只要稍微花些时间看看错误提示就能找到问题所在,而不是遇到错误信息就一股脑的往论坛里面塞。

其实我上面说那个回复你执行完了以后,完全可以搞明白是怎么回事了,但是估计你看都没看就发了

话说回来,你是 tmp/pids 这个目录没有建立,你需要

deployer@localhost:~$ mkdir ~/sites/test_app/tmp/pids

还是上面说的,错处的时候要注意看错误提示,其实大多数问题都还是写得很明显得,别那么担心,多试试就能搞定

#15 楼 @huacnlee 话说能不能自动生成 tmp 的?或者预先创建放个 .gitkeep 进去

#15 楼 @huacnlee 嗯 在研究中,,折腾了几遍还是没有解决。。我在研究下~

/var/rails/my_app/log/unicorn.log not writable 同样的问题 tmp 和 shared 都有 pids 文件夹,求教

需要 登录 后方可回复, 如果你还没有账号请 注册新账号