LoadError: cannot load such file -- parser/lexer

Hi, I’m getting an annoying and persistent error, only in the Travis CI building. I’m using the same configurations in my local environment, with no gem problems.

Could you please help us with that? Thanks.

You need to install a release of parser from RubyGems, not a checkout from Github.

Clean the cache and check where Bundler is installing it from with bundle --verbose.


Hi, thanks for your reply. (sorry, I did not thank you earlier)

I don’t have the parser directly added in my Gemfile. It is a dependency. I’m quite sure the environments are different, but why and how can I solve that?

My Gemfile looks like this:

# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.7.1'

gem 'rails'

gem 'addressable'
gem 'attr_encrypted'
gem 'carrierwave'
gem 'cloudinary'
gem 'coffee-rails'
gem 'devise'
gem 'discard'
gem 'figaro'
gem 'friendly_id'
gem 'histogram'
gem 'httparty'
gem 'jira-ruby', require: false
gem 'jquery-rails'
gem 'kaminari'
gem 'mini_magick'
gem 'oj'
gem 'pg'
gem 'rollbar'
gem 'sidekiq'
gem 'sidekiq-limit_fetch'
gem 'slack-notifier'
gem 'uglifier'
gem 'yui-compressor'

group :test, :development do
  gem 'brakeman'
  gem 'database_cleaner'
  gem 'fabrication'
  gem 'faker'
  gem 'parallel_tests'
  gem 'parser'
  gem 'rspec-collection_matchers'
  gem 'rspec-rails'
  gem 'rubocop'
  gem 'rubocop-performance'
  gem 'rubocop-rails'
  gem 'rubocop-rspec'
  gem 'shoulda-matchers'
  gem 'simplecov-parallel'
  gem 'webmock'
end

group :development do
  gem 'annotate'
  gem 'bullet'
  gem 'flamegraph'
  gem 'listen'
  gem 'memory_profiler'
  gem 'rack-mini-profiler', require: false
  gem 'rails_best_practices'
  gem 'rubycritic', require: false
  gem 'stackprof'
  gem 'traceroute'
  gem 'web-console'
end

group :test do
  gem 'rails-controller-testing'
  gem 'rspec_junit_formatter'
end

group :production do
  gem 'puma'
  gem 'rails_12factor'
end

You have a whole tree of gems under source control in flow_climate/vendor/bundle.

Which just happens to include a defective parser (without lexer.rb). So Bundler doesn’t actually download anything and uses this defective copy.

They have absolutely no business being under source control. Delete vendor from source control and add it to .gitignore. Also clear the Travis cache.

Thanks.

I’m using vendor/bundle to cache dependencies.

The solution is here if anyone is fighting a similar problem.

Best regards.

Use Travis cache to do that with cache: bundler. Keeping them under source control is going to be getting in your way as versions change. (And it’s also slowing down git commits considerably, wasting your time.)

As a rule of thumb, source control should not contain anything that is generated by the build – as duplication and a source of conflicts and weird errors (like this one) due to builds not being made from a clean state.

Ok. Thanks for your advice.