Checksum different before and after bundle install

bundler
config

#1

My CircleCI 2.0 config.yml:

version: 2
jobs:
  build:
    docker:
      - image: circleci/ruby:2.3.4
    working_directory: ~/repo
    steps:
      - checkout
      - run: echo "Running from .circleci/config.yml"
      - run: echo $CC_TEST_REPORTER_ID
      - run: ruby -v
      - run: gem install bundler -v 1.15.4
      - run: bundler -v
      - restore_cache:
          key: rails-{{ arch }}-{{ checksum "Gemfile.lock" }}
      - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
      - save_cache:
          key: rails-{{ arch }}-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
      - run: chmod +x ./cc-test-reporter
      - run: ./cc-test-reporter before-build
      - run: bundle exec rspec spec
      - run: ./cc-test-reporter after-build --exit-code $?

On the restore_cache step, it outputs:

No cache is found for key: rails-arch1-linux-amd64-6_62-2tqvY1YipbCiRdMsHC6hH0dE7Yy2rojGa7EQdF1a3QE=

On the save_cache step, it outputs:

Skipping cache generation, cache already exists for key: rails-arch1-linux-amd64-6_62-fpNAncficdF8R+0WmisGwNoy8Sv7EcxE_xkzAEZUo0o=
Found one created at 2017-10-12 15:23:50 +0000 UTC

The {{ checksum "Gemfile.lock" }} is different before and after running the command bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3.

When run on my local machine, all it does is create a vendor/bundle directory, but does not alter the Gemfile. Is there something I can do to ensure that the Gemfile.lock checksum does not change?


#2

I have the same issue but with Yarn, checksum gives me different checksums, this file never changes but gives me a different string:

version: 2  
jobs:                                                                              
  build:                                                                           
    working_directory: ~/app                                        
    docker:                                                                        
      - image: circleci/node:8.4                                                   
    steps:                                                                         
      - checkout                                                                   
      - restore_cache:                                                             
          key: dependency-cache-{{ checksum "yarn.lock" }}                         
      - run: npm install yarn                                                      
      - run: yarn install                                                                                                                                                    
      - save_cache:                                                                
          key: dependency-cache-{{ checksum "yarn.lock" }}                         
          paths:                                                                   
            - ~/app/node_modules                                    
            - ~/.cache           

#3

I haven’t resolved this issue yet. Worked through it with a few different folks with no luck.


#4

Same issue here. I cannot figure out why. I’ve already send support ticket and am waiting for response.


#5

Again, same issue here, but with package-lock.json


#6

We have the same issue with npm and package.json


#7

Same problem with package.json


#8

Usually this is caused by a change made to Gemfile where Gemfile.lock wasn’t also committed. Make sure you run bundle and commit Gemfile.lock.

Also, there may be a different version of bundler on CircleCI as opposed to your development environment. You can install a specific version of Bundler on CircleCI if needed, but it’s probably best to update your development environment’s Bundler to the latest release. gem install bundler


#9

I ran into this with npm install. TLDR: I didn’t have a new line at the end of my package.json.

I debugged this by rerunning a build with ssh and I ran a git status and noticed the package.json file did indeed have changes. Apparently, npm install will add a newline at the end of the file if there isn’t one.

For me, I had to add "files.insertFinalNewline": true to my vscode settings (because it was removing the newline :frowning:) and commit the file with a newline at the end.


#10

I solved my problem by using
npm i --no-save
The issue was caused by npm installing extra optional dependencies differently on different environments (fsevents from mac) that were committed in the npm–shrinkwrap.json.


#11

Exactly the same problem here. After doing:
cksum Gemfile.lock
bundle update fastlane
bundle check --path ../.bundle || bundle install --path ../.bundle
cksum Gemfile.lock

Before bundle install:
2779665191 3911 Gemfile.lock

After:
710379616 3911 Gemfile.lock


#12

Thanks for bringing this to our attention. We’ve added a Support Center article to help: https://support.circleci.com/hc/en-us/articles/360004632473-No-Cache-Found-and-Skipping-Cache-Generation


#13

It does appear to be an issue with yarn overwriting the lock file. Make sure that if you are using --frozen-lockfile that your yarn version actually supports that.


#14

I have same problem in my project. Unfortunately Circle CI uses different bundler version, which resulted to modifying the Gemfile.lock and checksum failed.

I solved this by using “Gemfile” instead of “Gemfile.lock” and seems working.

    - restore_cache:
        keys:
        - wc-gems-v4-{{ .Branch }}-{{ checksum "Gemfile" }}
    - run:
        name: Bundle
        command: |
            export PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH"
            bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
            #command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
    # Save dependency cache
    - save_cache:
        key: wc-gems-v4-{{ .Branch }}-{{ checksum "Gemfile" }}
        paths:
        - vendor/bundle
    

Seems to be working now.