由于Sqlite3问题,Rails新app_name失败

问题描述 投票:0回答:1

在Windows 10 64位上

使用Railsinstaller我安装了构建我的App所需的捆绑包。

安装后我检查了以下版本:

$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

$ rails -v
Rails 5.2.2

$ gem -v
2.5.2

$ bundler -v
Bundler version 2.0.1

$ sqlite3 --version
3.8.7.2 2014-11-18 20:57:56 2ab564bf9655b7c7b97ab85cafc8a48329b27f93

然后我开始rails new my_app_name结束了这些错误:

mkmf.log

package configuration for sqlite3 is not found
find_header: checking for sqlite3.h... -------------------- no

"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/ruby/backward -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c  -L. -LC:/RailsInstaller/Ruby2.3.3/lib -L.      -lmsvcrt-ruby230  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"gcc -E -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/ruby/backward -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat  conftest.c -o conftest.i"
conftest.c:5:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <sqlite3.h>
/* end */

--------------------

和gem_make.out

current directory: C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -r ./siteconf20190214-3564-1lpwzs0.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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
    --without-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=C:/RailsInstaller/Ruby2.3.3/bin/$(RUBY_BASE_NAME)
    --with-sqlcipher
    --without-sqlcipher
    --with-sqlite3-config
    --without-sqlite3-config
    --with-pkg-config
    --without-pkg-config
    --with-sqlcipher
    --without-sqlcipher
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/mkmf.log

extconf failed, exit code 1

我是Ruby的初学者,这是我第一次尝试创建应用程序,所以我可以进行实验。在我看来,问题与Sqlite3版本有关。我试图通过gembundle更新它但我又错了。

ruby-on-rails sqlite bundler
1个回答
0
投票

我有同样的问题,这些是我找到的两个解决方案。 1 *捆绑安装无法进入项目文件夹并修改Gemfile

gem 'sqlite3',  '1.3.11'

这一行改变了以下3个中的一些

gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"

gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby", branch: "add-gemspec"

gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"

它只适用于你安装了第一个Ruby Devkit或RubyInstaller以及后来的Rails安装程序,否则Rails Installer Ruby文件夹将被系统选为“ruby文件夹”

2 *你必须卸载RailsInstaller并删除剩余的文件夹(如果你在卸载程序结束后没有手动删除文件夹,当你执行gem命令时它会说“找不到RailsInstaller / Ruby2.3.​​3 / bin”文件夹)好吧,在通过命令行安装rails之后

gem install rails

并通过命令行MinGW安装

C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn

https://rubygems.org/下载gem文件并将其保存在本地并从文件安装

gem install --local C:\sqlite3-1.4.0.gem

第二个解决方案全局工作,因此您只需运行一次,下次执行rails new blog时,sqlite的问题将不再出现。只需确保在不在任何项目内的Sites文件夹上执行它,或者它只适用于该项目。

如果其中任何一个适合你,请随意尝试我在这里提到的方法之一https://mycodeissuesandfixes.blogspot.com/2019/02/ruby-on-rails-issue-about-sqlite-3-gem.html,我试图找到一个以上的解决方案超过一周。

祝好运!!希望它能帮到你

© www.soinside.com 2019 - 2024. All rights reserved.