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

Commit

Permalink
Remove newlines from Ruby activation script (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Nov 20, 2023
1 parent ee112d7 commit 8bc72ea
Showing 1 changed file with 10 additions and 2 deletions.
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("");

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

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

0 comments on commit 8bc72ea

Please sign in to comment.