Skip to content

Setting ENV["NO_COLOR"] = "1" inside Ruby does not disable colors #3

Open

Description

@davetron5000

It seems lipgloss reads the UNIX environment sometime early in its lifecycle such that changes to it later don't have any effect:

# test.rb
require "lipgloss"

if ARGV[0] == "no"
  puts "Disabling colors"
  ENV["NO_COLOR"] = "1"
end
puts Lipgloss::Style.new.foreground("#ffff00").render("HELLO")
> ruby test.rb
HELLO (in yellow)
> NO_COLOR=1 ruby test.rb
HELLO (not colored)
> ruby test.rb no
Disabling colors
HELLO (in yellow)
Image

Ultimatley, I'm trying to disable colors during a test. By the time my code runs, even in a test, whatever Lipgloss does to decide if colors should be used has been decided as "yes". In the go version's faq, it implies you can call lipgloss.SetColorProfile(termenv.TrueColor) (or some other value from termenv) to force its behavior. Is this possible with the Ruby version?

Activity

  1. marcoroth commented on Feb 17, 2026

    @marcoroth
    Owner

    Hey @davetron5000, thanks for reporting! That's a good question!

    Right now we don't have an equivalent API to do what the go version does. That said, I'm happy to see if we can make that work, either be providing the needed Ruby glue code or by adding proper bindings to the Go method.

    I'm assuming that the ENV variable is read at require time and that this might be why it's behaving in the way it does right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions