@@ -75,7 +75,10 @@ def remove_default_gem_files
7575 def remove_default_bin_dev
7676 bin_dev_path = File . join ( destination_root , "bin/dev" )
7777 return unless File . exist? ( bin_dev_path )
78+ return unless File . writable? ( bin_dev_path )
7879
80+ # Rails 7+ default bin/dev content
81+ # If Rails changes this default, this comparison will safely fail and preserve the file
7982 default_bin_dev = <<~RUBY . strip
8083 #!/usr/bin/env ruby
8184 exec "./bin/rails", "server", *ARGV
@@ -85,16 +88,17 @@ def remove_default_bin_dev
8588 return unless current_content == default_bin_dev
8689
8790 puts Rainbow ( "🗑️ Removing default bin/dev file to avoid conflicts..." ) . yellow
88- File . delete ( bin_dev_path )
91+ FileUtils . rm_f ( bin_dev_path )
8992 end
9093
9194 def remove_default_shakapacker_yml
9295 config_path = File . join ( destination_root , "config/shakapacker.yml" )
9396 return unless File . exist? ( config_path )
97+ return unless File . writable? ( config_path )
9498 return unless shakapacker_yml_matches_default? ( config_path )
9599
96100 puts Rainbow ( "🗑️ Removing default config/shakapacker.yml file to avoid conflicts..." ) . yellow
97- File . delete ( config_path )
101+ FileUtils . rm_f ( config_path )
98102 end
99103
100104 def shakapacker_yml_matches_default? ( config_path )
@@ -108,9 +112,8 @@ def shakapacker_yml_matches_default?(config_path)
108112 current_content = File . read ( config_path )
109113
110114 current_content == default_content
111- rescue StandardError => e
115+ rescue StandardError
112116 # If we can't compare, don't delete - better safe than sorry
113- puts Rainbow ( "⚠️ Could not verify shakapacker.yml: #{ e . message } " ) . yellow if options . verbose?
114117 false
115118 end
116119
0 commit comments