Custom formatter environment variables don't prevent internal quote conversion #8455

Open
opened 2026-02-16 18:10:01 -05:00 by yindo · 1 comment
Owner

Originally created by @pedropombeiro on GitHub (Feb 3, 2026).

Originally assigned to: @thdxr on GitHub.

Description

When configuring a custom Ruby formatter (rubocop) with RUBOCOP_OPTS environment variable to exclude Style/StringLiterals, the formatter runs correctly but an internal transformation still converts single quotes to double quotes.

Steps to Reproduce

  1. Create .opencode/opencode.jsonc with custom rubocop formatter:
{
  "formatter": {
    "rubocop": {
      "command": [".opencode/rubocop-format.sh", "$FILE"],
      "extensions": [".rb", ".rake", ".gemspec", ".ru"]
    }
  }
}
  1. Create wrapper script .opencode/rubocop-format.sh:
#!/bin/bash
export RUBOCOP_OPTS="--except Style/StringLiterals,Style/StringLiteralsInInterpolation"
cd "$(dirname "$0")/.." && bundle exec rubocop -a "$1"
  1. Edit a Ruby file that uses single quotes

Expected Behavior

Single quotes should be preserved since Style/StringLiterals is excluded via RUBOCOP_OPTS.

Actual Behavior

  • Rubocop formatting IS applied (e.g., spacing around operators is fixed)
  • Single quotes are converted to double quotes

Investigation Findings

  1. RUBOCOP_OPTS works correctly when running the wrapper script manually:

    $ .opencode/rubocop-format.sh spec/file_spec.rb
    # Single quotes preserved ✅
    
  2. The custom formatter IS being invoked by OpenCode (spacing fixes are applied)

  3. Something else converts quotes either before or after the custom formatter runs

  4. We also tried:

    • Using environment config key directly (same result)
    • Disabling built-in rubocop formatter and creating a differently-named custom one (same result)
    • Adding "disabled": true to built-in formatters (same result)

Environment

  • OpenCode version: latest
  • Ruby project using rubocop with single quote preference

Possible Cause

There appears to be an internal transformation (possibly in the Edit tool or file writing pipeline) that converts single quotes to double quotes regardless of formatter configuration.

Originally created by @pedropombeiro on GitHub (Feb 3, 2026). Originally assigned to: @thdxr on GitHub. ## Description When configuring a custom Ruby formatter (rubocop) with `RUBOCOP_OPTS` environment variable to exclude `Style/StringLiterals`, the formatter runs correctly but an internal transformation still converts single quotes to double quotes. ## Steps to Reproduce 1. Create `.opencode/opencode.jsonc` with custom rubocop formatter: ```jsonc { "formatter": { "rubocop": { "command": [".opencode/rubocop-format.sh", "$FILE"], "extensions": [".rb", ".rake", ".gemspec", ".ru"] } } } ``` 2. Create wrapper script `.opencode/rubocop-format.sh`: ```bash #!/bin/bash export RUBOCOP_OPTS="--except Style/StringLiterals,Style/StringLiteralsInInterpolation" cd "$(dirname "$0")/.." && bundle exec rubocop -a "$1" ``` 3. Edit a Ruby file that uses single quotes ## Expected Behavior Single quotes should be preserved since `Style/StringLiterals` is excluded via `RUBOCOP_OPTS`. ## Actual Behavior - ✅ Rubocop formatting IS applied (e.g., spacing around operators is fixed) - ❌ Single quotes are converted to double quotes ## Investigation Findings 1. **`RUBOCOP_OPTS` works correctly** when running the wrapper script manually: ``` $ .opencode/rubocop-format.sh spec/file_spec.rb # Single quotes preserved ✅ ``` 2. **The custom formatter IS being invoked** by OpenCode (spacing fixes are applied) 3. **Something else converts quotes** either before or after the custom formatter runs 4. We also tried: - Using `environment` config key directly (same result) - Disabling built-in `rubocop` formatter and creating a differently-named custom one (same result) - Adding `"disabled": true` to built-in formatters (same result) ## Environment - OpenCode version: latest - Ruby project using rubocop with single quote preference ## Possible Cause There appears to be an internal transformation (possibly in the Edit tool or file writing pipeline) that converts single quotes to double quotes regardless of formatter configuration.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8045: Opencode Doesn't Abide by Prompt or Run Formatter for Ruby Files - Similar issue where double quotes are converted to single quotes in Ruby files regardless of formatter configuration
  • #6876: Automatic stylistic changes due to linting errors are not ideal - Python files experiencing automatic quote conversion (single to double) despite custom formatter settings
  • #8387: On file edit it is also formatted - C++ files being completely reformatted on edit despite custom formatter configuration
  • #5591: Quotes in code getting stripped in model output - Quotes being removed from code despite being present in model responses

All these issues report similar symptoms: unwanted automatic transformations (especially quote conversions) occurring despite explicit formatter configurations or custom formatters being set.

Feel free to ignore if your specific case involves details not covered by these issues.

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #8045: Opencode Doesn't Abide by Prompt or Run Formatter for Ruby Files - Similar issue where double quotes are converted to single quotes in Ruby files regardless of formatter configuration - #6876: Automatic stylistic changes due to linting errors are not ideal - Python files experiencing automatic quote conversion (single to double) despite custom formatter settings - #8387: On file edit it is also formatted - C++ files being completely reformatted on edit despite custom formatter configuration - #5591: Quotes in code getting stripped in model output - Quotes being removed from code despite being present in model responses All these issues report similar symptoms: unwanted automatic transformations (especially quote conversions) occurring despite explicit formatter configurations or custom formatters being set. Feel free to ignore if your specific case involves details not covered by these issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8455