Skip to content

Commit

Permalink
Avoid requiring json for chruby activation
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Aug 12, 2024
1 parent aa56380 commit 6f7bd11
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vscode/src/ruby/chruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,17 @@ export class Chruby extends VersionManager {
"end",
`newer_gem_home = File.join(File.dirname(user_dir), "${rubyVersion.version}")`,
"gems = (Dir.exist?(newer_gem_home) ? newer_gem_home : user_dir)",
"data = { defaultGems: Gem.default_dir, gemHome: gems, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION }",
"STDERR.print(JSON.dump(data))",
`STDERR.print([Gem.default_dir, gems, !!defined?(RubyVM::YJIT), RUBY_VERSION].join("ACTIVATION_SEPARATOR"))`,
].join(";");

const result = await this.runScript(
`${rubyExecutableUri.fsPath} -W0 -rjson -e '${script}'`,
`${rubyExecutableUri.fsPath} -W0 -e '${script}'`,
);

return this.parseWithErrorHandling(result.stderr);
const [defaultGems, gemHome, yjit, version] = result.stderr.split(
"ACTIVATION_SEPARATOR",
);

return { defaultGems, gemHome, yjit: yjit === "true", version };
}
}

0 comments on commit 6f7bd11

Please sign in to comment.