From 990c817571844462906b4ac7a58e64640be660e2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 20:18:40 +0200 Subject: fix bin/rcm to fall back to lib/dsl when gem is not installed --- bin/rcm | 9 ++++++++- examples/cli/config.rb | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/rcm b/bin/rcm index 2a7b6cd..240e217 100755 --- a/bin/rcm +++ b/bin/rcm @@ -14,5 +14,12 @@ unless File.exist?(config_file) exit 1 end -require 'rcm' +# Try the installed gem first; fall back to the lib/ directory relative to +# this script so the CLI works directly from a repository checkout. +begin + require 'rcm' +rescue LoadError + require_relative '../lib/dsl' +end + load config_file diff --git a/examples/cli/config.rb b/examples/cli/config.rb index 84fa8f1..2828d7c 100755 --- a/examples/cli/config.rb +++ b/examples/cli/config.rb @@ -7,9 +7,7 @@ # rcm config.rb --hosts earth,mars # limit to specific hosts # rcm config.rb # apply configuration # -# Requires rcm to be installed as a gem, or adjust the path below: -# require_relative '../../lib/dsl' -require 'rcm' +# rcm is already loaded by the bin/rcm CLI tool before this file is executed. configure do # Only apply the block below when running on host 'earth'. -- cgit v1.2.3