Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Remove newlines from Ruby activation script #904

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
vinistock marked this conversation as resolved.
Show resolved Hide resolved

command += `${ruby} -rjson -e "${script}"`;

if (this.shell) {
command += "'";
Expand Down