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

Alert shadowenv users about missing Ruby #873

Merged
merged 1 commit into from
Nov 6, 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
10 changes: 10 additions & 0 deletions src/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down