【发布时间】:2022-03-06 02:18:49
【问题描述】:
我是 Rails 新手,我正在从 The Ruby on Rails 教程中学习它。
当我在 Gemfile 中使用 gem 'sqlite3' 时,bundle install 命令显示此错误;
An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'`
succeeds before bundling.
In Gemfile:
sqlite3
我在这里找到了解决方案 - https://medium.com/@declancronje/installing-and-troubleshooting-ruby-on-rails-sqlite3-windows-10-fix-87c8886d03b,这表明应该将 gem 'sqlite3' 替换为 gem ‘sqlite3’, git: “https://github.com/larskanis/sqlite3-ruby", branch: “add-gemspec”。在更新 Gemfile 后运行 bundle install 时,所有必需的 gem,包括 sqlite3,似乎都已安装;
Bundle complete! 15 Gemfile dependencies, 70 gems now installed.
Use 'bundle info [gemname]' to see where a bundled gem is installed.
但在运行命令sqlite3 --version 时,我仍然收到错误消息,提示
'sqlite3' is not recognized as an internal or external command,
operable program or batch file.
我还提到了各种 stackoverflow 答案,但它们似乎都不起作用。 gem install sqlite3 也不起作用。
请帮忙。
【问题讨论】:
-
您是否尝试过单独安装预编译的 SQLIte 二进制文件? sqlite.org/download.html
-
@rmlockerd,不,我没有。感谢您的建议。打算试试看。
-
@rmlockerd,抱歉没用。有没有其他方法可以解决这个问题?
-
sqlite 本身必须在安装 ruby gem 之前安装:tutorialspoint.com/sqlite/sqlite_installation.htm
-
我想出了如何解决它。我刚刚卸载了 Ruby 和所有的 gem(我想我不小心弄乱了其中一个文件),然后重新安装了 Ruby。在使用
gem install rails并运行rails new命令后,我使用命令ruby bin/rails server启动了服务器。 @rmlockerd @Sharagoz 谢谢,使用预编译的二进制文件安装 sqlite3 效果很好。
标签: ruby-on-rails sqlite gemfile