Skip to content

No interactive input to Rails server #197

@Jimjamjimbo

Description

@Jimjamjimbo

Starting from this Ruby template with the Shopify CLI (shopify app init --template=ruby) and adding a debugger line to HomeController#index like so:

# frozen_string_literal: true

class HomeController < ApplicationController
  include ShopifyApp::EmbeddedApp
  include ShopifyApp::EnsureInstalled
  include ShopifyApp::ShopAccessScopesVerification

  DEV_INDEX_PATH = Rails.root.join("frontend")
  PROD_INDEX_PATH = Rails.public_path.join("dist")

  def index
    if ShopifyAPI::Context.embedded? && (!params[:embedded].present? || params[:embedded] != "1")
      redirect_to(ShopifyAPI::Auth.embedded_app_url(params[:host]), allow_other_host: true)
    else
      contents = File.read(File.join(Rails.env.production? ? PROD_INDEX_PATH : DEV_INDEX_PATH, "index.html"))
      contents.sub!("%VITE_SHOPIFY_API_KEY%", ShopifyApp.configuration.api_key)
      debugger
      render(plain: contents, content_type: "text/html", layout: false)
    end
  end
end

Run shopify app dev and visit the app page. The Rails app pauses at the debugger line as expected, but there's absolutely no way to input anything - Shopify CLI seems to eat all input.

C:/Development/shopify_app_debugger_example/app-debugger-example/web/app/controllers/home_controller.rb
16:58:54 │               web-backend │     12|     if ShopifyAPI::Context.embedded? && (!params[:embedded].present? || params[:embedded] != "1")
16:58:54 │               web-backend │     13|       redirect_to(ShopifyAPI::Auth.embedded_app_url(params[:host]), allow_other_host: true)
16:58:54 │               web-backend │     14|     else
16:58:54 │               web-backend │     15|       contents = File.read(File.join(Rails.env.production? ? PROD_INDEX_PATH : DEV_INDEX_PATH,
"index.html"))
16:58:54 │               web-backend │     16|       contents.sub!("%VITE_SHOPIFY_API_KEY%", ShopifyApp.configuration.api_key)
16:58:54 │               web-backend │ =>  17|       debugger
16:58:54 │               web-backend │     18|       render(plain: contents, content_type: "text/html", layout: false)
16:58:54 │               web-backend │     19|     end
16:58:54 │               web-backend │     20|   end                                                                                                  
16:58:54 │               web-backend │     21| end                                                                                                    
16:58:54 │               web-backend │ =>#0     HomeController#index at                                                                               
C:/Development/shopify_app_debugger_example/app-debugger-example/web/app/controllers/home_controller.rb:17                                            
16:58:54 │               web-backend │   #1     ActionController::BasicImplicitRender#send_action(method="index", args=[]) at                         
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/actionpack-7.1.6/lib/action_controller/metal/basic_implicit_render.rb:6                                        
16:58:54 │               web-backend │   # and 85 frames (use `bt' command for all frames)                                                            
16:58:54 │               web-backend │ (rdbg)
                                                                                                                                                      
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────               
│ (d) Dev status │ (a) App info │ (s) Store info │                                                                             (q) Quit               

 ✅ Ready, watching for changes in your app

 › (g) Open GraphiQL (Admin API) in your browser
 › (p) Preview in your browser

 Preview URL: ***
 GraphiQL URL: ***

pry, byebug, and debugger are all commonly used gems for debugging Rails apps so this feels like a big issue out of the box. Can the template be fixed to make input possible? If not, could the README or wiki include detailed instructions on a potential workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions