From 8bc72eaccaed283bfc0569ee078bda56061243bc Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Mon, 20 Nov 2023 10:35:04 -0500 Subject: [PATCH] Remove newlines from Ruby activation script (#904) --- src/ruby.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ruby.ts b/src/ruby.ts index 6f3ffb94..d795aec4 100644 --- a/src/ruby.ts +++ b/src/ruby.ts @@ -169,8 +169,16 @@ export class Ruby { private async activate(ruby: string) { let command = this.shell ? `${this.shell} -ic '` : ""; - command += `${ruby} -rjson -e "STDERR.printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, - JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))"`; + + // The Ruby activation script is intentionally written as an array that gets joined into a one liner because some + // terminals cannot handle line breaks. Do not switch this to a multiline string or that will break activation for + // those terminals + const script = [ + "STDERR.printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, ", + "JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))", + ].join(""); + + command += `${ruby} -rjson -e "${script}"`; if (this.shell) { command += "'";