gpt4 book ai didi

ruby-on-rails - Rails新的app_name由于Sqlite3问题而失败

转载 作者:行者123 更新时间:2023-12-03 19:13:51 24 4
gpt4 key购买 nike

在Windows 10 64位上

使用Railsinstaller,我安装了构建应用程序所需的捆绑程序。

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

$ 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更新它,但是又出现了错误。

最佳答案

我有同样的问题,这是我找到的两个解决方案。
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中提到的一种方法,我已经尝试了一个多星期的解决方案。

祝好运!!希望对您有帮助

关于ruby-on-rails - Rails新的app_name由于Sqlite3问题而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54694428/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com