【问题标题】:I can't run rails server我无法运行 Rails 服务器
【发布时间】:2022-01-21 11:44:05
【问题描述】:

怎么样了? 我尝试使用 Ruby on Rails 创建我的第一个应用程序,我可以创建项目但无法运行服务器。 我的操作系统是 Windows。 我安装了 Node、Yarn、Ruby、Rails、Sqlite3。 当我尝试运行“rails s”时出现此消息

Could not find gem 'sqlite3' in locally installed gems.
Run `bundle install` to install missing gems.

我运行命令“bundle install”、“bundle update”但不起作用。当我运行“捆绑安装”时出现此消息:

An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.

In Gemfile:
  sqlite3

当我验证 sqlite3 的版本时: enter image description here 我尝试编辑 Gemfile:

gem 'sqlite3', '~> 1.4.2'

并尝试以这种方式安装:

gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'

我也尝试了以下步骤: https://www.youtube.com/watch?v=cAseoJeNG8I

我遵循 windows 用户文档中的建议并在 Bash 上运行“bin/rails s”,但仍然出现同样的问题。 我在这里阅读了类似问题的其他答案,但没有帮助我,为此我提出了这个问题。 如果您有什么遗漏的问题,请告诉我,我会提供信息。 谢谢大家。

【问题讨论】:

    标签: ruby-on-rails windows


    【解决方案1】:

    你试过删除gemfile.lock吗?尝试删除,然后再次输入bundle install

    【讨论】:

    • 我在我的项目中搜索并且没有 gemfile.lock 只有 gemfile。重新安装 Rails 是个好主意吗?
    • 也许这是个好主意。据我所知 gemfile.lock 是强制性的,因为它向我们展示了我们所有已安装的 gem。试试看并给我们反馈
    • 现在生成 gemfile.lock。但是当我尝试运行 rails s 时,会出现此消息 cannot load such file -- sqlite3/sqlite3_native (LoadError)
    • link 尝试解决此链接中的问题。
    【解决方案2】:

    出现上述错误是因为您的系统上没有安装sqlite3。

    第一步:-首先,按照提到here的步骤在你的系统上安装sqlite3

    第二步:-运行bundle install

    【讨论】:

    • 当我验证版本时,会出现:3.37.0 2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a。我将 sqlite3 dll/exe 放在 bin 文件夹中,您提到的问题中对此有何描述。我将版本放在 gemfile '1.4.1' 中也不起作用。只是使用 autoconfig 提到的步骤,因为我不知道如何编译 .configure。
    猜你喜欢
    • 2012-04-22
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2016-05-12
    相关资源
    最近更新 更多