After adding a Gem, it says There was an error parsing `Gemfile`

Target person

As the title says, if you add a Gem, you get the error message There was an error parsing Gemfile

Read the error statement (understand the current situation)

Described in Gemfile to put faker in development environment and test environment.

group :development, :test do

   **gem 'faker'**← Add this

end

And even though I try bundle install,

bundle install

I get an error in the title.

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: faker (>= 0) and faker (= 2.1.2). Bundler cannot continue.

 #  from /Users/XXXX/XXXX/XXXX/Gemfile:88
 #  -------------------------------------------
 #  gem 'dotenv-rails'
 >  gem 'faker',                   '2.1.2'
 #  gem 'carrierwave'
 #  -------------------------------------------

When I read the error statement,

An error occurred in parsing Gemfile`. You cannot specify the same gem twice with different version requirements. You specified faker (> = 0) and faker (= 2.1.2), so Bundler cannot continue.

It seems that faker is already included because it is said. As a matter of fact, there was already a description of faker at the bottom of the Gemfile.

gem 'faker',                   '2.1.2'

As noted in the error statement I tried to specify the same gem twice with different version requirements. It's said exactly, and there's no gu sound.

solution

The solution is that faker can be used in all environments including the test environment, so in this case it will be "do not add gemfile". It may be different from the solution, but you know the cause. that's all.

Recommended Posts

After adding a Gem, it says There was an error parsing `Gemfile`
I get an error when adding a dependency
[Java] Adding an element to the Collection causes a compile error