From 1bed7530cb5e4d336e4a4a149911aad7e3fdd3a1 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 3 Nov 2023 14:38:34 -0400 Subject: [PATCH] Alert shadowenv users about missing Ruby --- src/ruby.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ruby.ts b/src/ruby.ts index 6be15c4d..be3ff2ee 100644 --- a/src/ruby.ts +++ b/src/ruby.ts @@ -150,6 +150,16 @@ export class Ruby { // eslint-disable-next-line no-process-env const env = { ...process.env, ...JSON.parse(result.stderr).exported }; + // If the configurations under `.shadowenv.d/` point to a Ruby version that is not installed, shadowenv will still + // return the complete environment without throwing any errors. Here, we check to see if the RUBY_ROOT returned by + // shadowenv exists. If it doens't, then it's likely that the Ruby version configured is not installed + if (!fs.existsSync(env.RUBY_ROOT)) { + throw new Error( + `The Ruby version configured in .shadowenv.d is ${env.RUBY_VERSION}, \ + but the Ruby installation at ${env.RUBY_ROOT} does not exist`, + ); + } + // The only reason we set the process environment here is to allow other extensions that don't perform activation // work properly // eslint-disable-next-line no-process-env