Android - Screengrab wrong ruby version

I’m trying to take some screenshots while testing my app with screengrab

But, I’m getting an error about ruby version when installing screengrab:

sudo gem install screengrabFetching: json-2.0.2.gem ( 18%)Fetching: json-2.0.2.gem (100%)
ERROR:  Error installing screengrab:
	json requires Ruby version ~> 2.0.

sudo gem install screengrab returned exit code 1

Action failed: sudo gem install screengrab 

I’ve already set ruby version to 2.3.1 in circle.yml:

machine:
  ruby:
    version: ruby-2.3.1

  environment:
    TERM: "dumb"
    ADB_INSTALL_TIMEOUT: "10"
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'

dependencies:
  pre:
    - ruby -v
    - sudo gem install screengrab

test:
  override:
    # start the emulator
    - emulator -avd circleci-android22 -no-audio -no-window:
        background: true
        parallel: true
    # wait for it to have booted
    - circle-android wait-for-boot
    # unlock the emulator screen
    - sleep 30
    - adb shell input keyevent 82
    # run tests  against the emulator.
    - ./gradlew connectedMockDebugAndroidTest -PdisablePreDex
    # copy the build outputs to artifacts
    - cp -r app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
    # Execute test for screenshots
    - screengrab
    # Copy screengrab screenshots
    - cp -r fastlane $CIRCLE_ARTIFACTS

When the command ruby -v is executed I got the following output:

ruby -vruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

Link to build: https://circleci.com/gh/ceduliocezar/lux/31