Command Line Interface (CLI)

codeclimate is a command line interface for the Code Climate analysis platform. It allows you to run Code Climate engines on your local machine inside of Docker containers.

The Code Climate CLI is open source. Detailed installation and usage instructions are included in the CLI repo.

The following is a list of common error messages and issues encountered when working with the CLI.

Error: "Permission denied @ rb_sysopen"

This error may be thrown when running codeclimate analyze. It is thrown when the Code Climate CLI attempts to analyze a file or directory that it does not have access to. The file/directory in question is listed in the error message. For example, ruby.rb is the problem file in the follow error output: Permission denied @ rb_sysopen - /code/ruby.rb (Errno::EACCES)

Note: In this example, ruby.rb lives off the root of the repository that is being analyzed. The /code folder is created automatically by our CLI, only within the engine's Docker container. All project code is moved into this folder, just for the analysis.

To resolve this issue:

  • If the error being thrown indicates your .codeclimate.yml is the problem file, change its file-level permissions so that "everyone" can access it.

  • Sometimes this error is thrown on a file that is likely not a good fit for static analysis (e.g., an SSH key). If so, exclude this file (see our sample .codeclimate.yml file for the appropriate syntax to apply exclusions).

  • If this fix is not appropriate, change the file's permissions so it can be accessed by our CLI.

Error: "Are you trying to connect to a TLS-enabled daemon without TLS?"

This error may be thrown when attempting to install or use the Code Climate CLI. It indicates that the correct environment variables are not set for Docker. The three missing variables are DOCKER_HOST, DOCKER_CERT_PATH, and DOCKER_TLS_VERIFY.

To resolve this issue:

If you are using boot2docker, run the following commands to automatically set these environment variable for your current session:

$ boot2docker up
$ eval "$(boot2docker shellinit)"

Tip: To just display the value of these variables (without setting them) you can use boot2docker shellinit.

Tip: To ensure these environment variables are loaded automatically for future sessions, set them in your .bash_profile or .zsh_profile file.

Error: "(CC::Analyzer::Engine::EngineFailure) engine <engine_name> failed with status <138 or 139> and stderr"

This error may be thrown when running codeclimate analyze. It indicates that a memory exception was encountered by the Code Climate CLI.

To resolve this issue:

The only work-around that is currently available is reducing the number of source files in the project being analyzed. To do so, exclude them from our analysis (see our sample .codeclimate.yml file for the appropriate syntax to apply exclusions)

Error: "WARNING: unknown engine name: "

This error may be thrown if the Code Climate CLI version you have installed is older. In this event, you'll want to update your CLI to know about a newer engine.

To resolve this issue:

Update the Code Climate CLI by running brew update && brew upgrade codeclimate. Once the update is complete, try installing and using the engine.

Error: "No CODECLIMATE_REPO_TOKEN found. A CODECLIMATE_REPO_TOKEN must be specified as an environment variable."

This error may be thrown if you have both our CLI and a previous version of our JavaScript test reporter installed on the same machine. Since the binaries for both of these components share the same name (codeclimate), attempting to call our CLI (e.g., codeclimate analyze) may incorrectly call our JavaScript test reporter, which then complains that it doesn't have a required test coverage token. Our CLI does not need a token.

To resolve this issue:

Update our JavaScript test reporter to version 0.1.0 or higher.

Error: "Your Docker setup does not support the codeclimate wrapper script"

This error may be thrown when attempting to run a CLI command (e.g., codeclimate analyze). In most cases this error indicates that boot2docker is in the "poweroff" state on your machine.

Below is the full error message:

Your Docker setup does not support the codeclimate wrapper script:
  > /var/run/docker.sock must exist as a Unix domain socket
We require a local Docker daemon that supports communication via the default socket path.
Please use `docker run' to run the `codeclimate/codeclimate' image directly.
See https://github.com/codeclimate/codeclimate for more details.

To resolve this issue:

Run boot2docker start. Try again to use the CLI.

Error: "An error occurred trying to connect: [...] x509: certificate is valid for..."

This error may be thrown when attempting to run a CLI command (e.g., codeclimate analyze). It is caused by a known issue in boot2docker Version 1.7.0. For more info, see boot2docker's GitHub site.

To resolve this issue:

There is no formal resolution currently available. For the time-being, the work-around is to run boot2docker ssh 'sudo /etc/init.d/docker restart. This will resolve the certificate errors until boot2docker restarts, at which point the same command must be run again.