bundle install - Gemfile 没有指定任何依赖项 - 即使我在包含 Gemfile 的目录中

bundle install - The Gemfile specifies no dependencies - Even though I'm in the directory that contains the Gemfile

我正在尝试按照指南使用 rspec 进行测试。我使用 bundle init 来创建 Gemfile。然后我尝试执行 bundle install (按照指南)来安装所有的 gem。我确保位于包含 gemfile 的同一文件夹中。但是,我一直收到这个:

The Gemfile specifies no dependencies

Bundle complete! 0 Gemfile dependencies, 1 gem now installed.

Use bundle info [gemname] to see where a bundled gem is installed.

我的 Gemfile(在我执行 bundle init 之后)如下所示:

frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "rails"

我用的是ruby2.7.1.

如有任何帮助,我们将不胜感激。

我一步一步地尝试了这个,只有当我没有在我的 Gemfile 中指定任何 gem 时才会出现这个错误。我猜 bundle init 命令创建了一个带有 gem 'rails' 行的 Gemfile 被注释。请验证您的 Gemfile 并确保您至少添加了一个 gem 到您的 Gemfile 或检查 gem 'rails' 行是否仍然被注释掉。