Back to all reviewers

Avoid environment-specific paths

deeplearning4j/deeplearning4j
Based on 3 comments
Shell

Always use environment variables or configuration mechanisms instead of hardcoding paths to compilers, tools, or directories. Hardcoded paths create dependencies on specific environments and break compatibility across different platforms and CI systems.

Configurations Shell

Reviewer Prompt

Always use environment variables or configuration mechanisms instead of hardcoding paths to compilers, tools, or directories. Hardcoded paths create dependencies on specific environments and break compatibility across different platforms and CI systems.

Bad:

#!/bin/bash
CXX=/usr/bin/g++

Good:

#!/bin/bash
# Use environment variable if set, otherwise use default
CXX=${CXX:-g++}

For specialized environment paths, use specific environment variables that users can customize:

Bad:

export CMAKE_COMMAND="$CMAKE_COMMAND -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake"

Good:

# Allow users to specify RPI_HOME environment variable
export RPI_HOME=${RPI_HOME:-$HOME/raspberrypi}
export CMAKE_COMMAND="$CMAKE_COMMAND -D CMAKE_TOOLCHAIN_FILE=$RPI_HOME/pi.cmake"

This approach ensures scripts remain portable across different development environments, CI systems, and operating systems.

3
Comments Analyzed
Shell
Primary Language
Configurations
Category

Source Discussions