Skip to content

exec: "bash": cannot run executable found relative to current directory #8610

Closed
@limingjie

Description

@limingjie

Board

ESP32S3 Dev Module, ESP32 Dev Module

Device Description

The issue happens while compiling, a dev board is not required to reproduce the issue.

Version

2.0.12

IDE Name

Arduino IDE Version: 2.2.1

Operating System

macOS Ventura 13.5

Description

I saw this issue in a WeChat group. The compilation step fails if the PATH variable has a relative path. This is probably due to the security restriction of exec() that is used by Arduino, using a relative path gives the hacker a chance to replace the binary and potentially gain restricted access.

Reproduce Steps

The issue reproduces in macOS.

  1. If you are not using zsh, change to zsh.
chsh -s /bin/zsh
  1. Add a relative path into the $PATH env var. For example, append the following line at the end of ~/.zshrc.
export PATH="./bin:$PATH"
  1. Close and restart Arduino IDE 2.2.1.
  2. Select board ESP32S3 Dev Module or ESP32 Dev Module.
  3. Try compiling any example sketch.

Solution

In platform.txt, replace bash with /usr/bin/env bash to ignore the search path, the issue is gone.

Error Log

FQBN: esp32:esp32:esp32s3
Using board 'esp32s3' from platform in folder: /Users/mingjie.li/Library/Arduino15/packages/esp32/hardware/esp32/2.0.12
Using core 'esp32' from platform in folder: /Users/mingjie.li/Library/Arduino15/packages/esp32/hardware/esp32/2.0.12

bash -c "[ ! -f \"/Users/mingjie.li/Documents/Arduino/BlinkRGB\"/partitions.csv ] || cp -f \"/Users/mingjie.li/Documents/Arduino/BlinkRGB\"/partitions.csv \"/private/var/folders/np/q95x8dw97611nmm409kr7znc0000gp/T/arduino/sketches/094B1C89E47FE775C5AE52E3FF7017B5\"/partitions.csv"

exec: "bash": cannot run executable found relative to current directory

Compilation error: exec: "bash": cannot run executable found relative to current directory

Sketch

Any sketch will do, to quickly reproduce it, I used the blink one.

/*
  BlinkRGB

  Demonstrates usage of onboard RGB LED on some ESP dev boards.

  Calling digitalWrite(RGB_BUILTIN, HIGH) will use hidden RGB driver.
    
  RGBLedWrite demonstrates controll of each channel:
  void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val)

  WARNING: After using digitalWrite to drive RGB LED it will be impossible to drive the same pin
    with normal HIGH/LOW level
*/
//#define RGB_BRIGHTNESS 64 // Change white brightness (max 255)

// the setup function runs once when you press reset or power the board

void setup() {
  // No need to initialize the RGB LED
}

// the loop function runs over and over again forever
void loop() {
#ifdef RGB_BUILTIN
  digitalWrite(RGB_BUILTIN, HIGH);   // Turn the RGB LED white
  delay(1000);
  digitalWrite(RGB_BUILTIN, LOW);    // Turn the RGB LED off
  delay(1000);

  neopixelWrite(RGB_BUILTIN,RGB_BRIGHTNESS,0,0); // Red
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,RGB_BRIGHTNESS,0); // Green
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,0,RGB_BRIGHTNESS); // Blue
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,0,0); // Off / black
  delay(1000);
#endif
}

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions