5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rails-mcp-server/utilities/run_process.rb', line 5
def self.execute_rails_command(project_path, command)
subprocess_env = ENV.to_h.merge(Bundler.original_env).merge(
"BUNDLE_GEMFILE" => File.join(project_path, "Gemfile")
)
RailsMcpServer.log(:debug, "Executing: #{command}")
stdout_str, stderr_str, status = Open3.capture3(subprocess_env, command, chdir: project_path)
if status.success?
RailsMcpServer.log(:debug, "Command succeeded")
stdout_str
else
RailsMcpServer.log(:error, "Command failed with status: #{status.exitstatus}")
RailsMcpServer.log(:error, "stderr: #{stderr_str}")
"Error executing Rails command: #{command}\n\n#{stderr_str}"
end
rescue => e
RailsMcpServer.log(:error, "Exception executing Rails command: #{e.message}")
"Exception executing command: #{e.message}"
end
|