Skip to content

Commit dadd3df

Browse files
justin808claude
andcommitted
Fix regression: Only check Gemfile text for Shakapacker presence
The regression was caused by checking lockfile and bundler specs for Shakapacker, which finds it as a dependency of react_on_rails even when it's not explicitly configured in the project. Fixed by only checking if 'gem "shakapacker"' is explicitly declared in the project's Gemfile, not just available as a transitive dependency. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c261b81 commit dadd3df

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,21 @@ def check_node_version
118118
end
119119

120120
def ensure_shakapacker_installed
121-
return if shakapacker_binaries_exist?
121+
return if shakapacker_configured?
122122

123123
print_shakapacker_setup_banner
124124
ensure_shakapacker_in_gemfile
125125
install_shakapacker
126126
finalize_shakapacker_setup
127127
end
128128

129-
# Checks whether "shakapacker" is present in the *current bundle*,
130-
# without loading it. Prioritizes Gemfile.lock (cheap + accurate),
131-
# then Bundler's resolved specs, and finally a light Gemfile scan.
129+
# Checks whether "shakapacker" is explicitly declared in this project's Gemfile.
130+
# We only check the Gemfile text, not lockfile or dependencies, because
131+
# shakapacker might be present as a dependency of react_on_rails but not
132+
# properly configured for this specific Rails application.
132133
def shakapacker_in_gemfile?
133134
gem_name = "shakapacker"
134-
135-
return true if shakapacker_loaded_in_process?(gem_name)
136-
return true if shakapacker_in_lockfile?(gem_name)
137-
return true if shakapacker_in_bundler_specs?(gem_name)
138-
return true if shakapacker_in_gemfile_text?(gem_name)
139-
140-
false
135+
shakapacker_in_gemfile_text?(gem_name)
141136
end
142137

143138
def add_bin_scripts
@@ -190,6 +185,13 @@ def shakapacker_binaries_exist?
190185
File.exist?("bin/shakapacker") && File.exist?("bin/shakapacker-dev-server")
191186
end
192187

188+
def shakapacker_configured?
189+
# Check for essential shakapacker configuration files and binaries
190+
shakapacker_binaries_exist? &&
191+
File.exist?("config/shakapacker.yml") &&
192+
File.exist?("config/webpack/webpack.config.js")
193+
end
194+
193195
def print_shakapacker_setup_banner
194196
puts Rainbow("\n#{'=' * 80}").cyan
195197
puts Rainbow("🔧 SHAKAPACKER SETUP").cyan.bold

0 commit comments

Comments
 (0)