Skip to content

Commit a55cdc2

Browse files
justin808claude
andcommitted
Fix bundler isolation for generate_packs in example apps
Use unbundled_sh_in_dir to properly isolate the bundler environment when running generate_packs in generated example apps. The previous approach with BUNDLE_GEMFILE env var didn't work because bundler still used cached gem paths from the parent rake context. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 34fa151 commit a55cdc2

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

react_on_rails/rakelib/shakapacker_examples.rake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
114114
sh_in_dir(example_type.dir, "npm install")
115115
# Generate the component packs after running the generator to ensure all
116116
# auto-bundled components have corresponding pack files created.
117-
if example_type.minimum_versions
118-
# For minimum version examples, use BUNDLE_GEMFILE to ensure bundler uses
119-
# the generated app's Gemfile and not any parent workspace's bundle,
120-
# which could have different gem versions. Also use BUNDLE_FROZEN=false
121-
# to allow the lockfile to be updated.
122-
gemfile_path = File.join(example_type.dir, "Gemfile")
123-
sh_in_dir(example_type.dir,
124-
"BUNDLE_GEMFILE=#{gemfile_path} BUNDLE_FROZEN=false bundle exec rake react_on_rails:generate_packs")
125-
else
126-
sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs")
127-
end
117+
# Use unbundled_sh_in_dir to ensure we're using the generated app's Gemfile
118+
# and gem versions, not the parent workspace's bundle context.
119+
unbundled_sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs")
128120
end
129121
end
130122

0 commit comments

Comments
 (0)