Search code examples
ruby-on-railsruby-on-rails-6.1

How do I determine the cause of a ActionView::Template::Error (SyntaxError: [stdin]:15:1: unexpected indentation)


I have a rails app and I had to revert a lot of commits. Now, when I try to view the app locally localhost:3000, I get an error I haven't seen before.

Processing by MainController#index as HTML
  Rendering layout layouts/lmt.html.erb
  Rendering main/index.html.erb within layouts/lmt
  Event Load (1.0ms)  SELECT "events".* FROM "events"
  ↳ app/views/main/index.html.erb:14
  Rendered main/index.html.erb within layouts/lmt (Duration: 357.4ms | Allocations: 238507)
  Rendered layout layouts/lmt.html.erb (Duration: 357.6ms | Allocations: 238584)
Completed 500 Internal Server Error in 358ms (ActiveRecord: 1.0ms | Allocations: 239010)
 
ActionView::Template::Error (SyntaxError: [stdin]:15:1: unexpected indentation):
  
(execjs):7539:8
(execjs):7557:14
(execjs):1:32

In the browser, I click the Full Trace link and I see the below output. It shows the execjs lines above, but I've never touched that file and don't know where it is.

I read a couple threads that were more target oriented, like CoffeeScripts or python and one or two mentioned that it might be an editor issue. I use sublime-text

SyntaxError: [stdin]:15:1: unexpected indentation

Rails.root: /home/jdc44/Websites/LMT
Application Trace | Framework Trace | Full Trace
compile ((execjs):7528:19)
eval (eval at <anonymous> ((execjs):7539:8), <anonymous>:1:10)
(execjs):7539:8
(execjs):7557:14
(execjs):1:32
Object.<anonymous> ((execjs):1:50)
Module._compile (node:internal/modules/cjs/loader:1198:14)
Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
Module.load (node:internal/modules/cjs/loader:1076:32)
Function.Module._load (node:internal/modules/cjs/loader:911:12)
Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
node:internal/main/run_main_module:22:47
execjs (2.9.1) lib/execjs/external_runtime.rb:40:in `exec'
execjs (2.9.1) lib/execjs/external_runtime.rb:22:in `eval'
execjs (2.9.1) lib/execjs/external_runtime.rb:47:in `call'
coffee-script (2.4.1) lib/coffee_script.rb:78:in `compile'
sprockets (4.2.1) lib/sprockets/coffee_script_processor.rb:24:in `block in call'
sprockets (4.2.1) lib/sprockets/cache.rb:92:in `fetch'
sprockets (4.2.1) lib/sprockets/coffee_script_processor.rb:23:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:33:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/bundle.rb:41:in `block in call'
sprockets (4.2.1) lib/sprockets/utils.rb:175:in `dfs'
sprockets (4.2.1) lib/sprockets/bundle.rb:42:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/bundle.rb:32:in `block in call'
/home/jdc44/.rvm/rubies/ruby-3.1.1/lib/ruby/3.1.0/set.rb:511:in `each_key'
/home/jdc44/.rvm/rubies/ruby-3.1.1/lib/ruby/3.1.0/set.rb:511:in `each'
sprockets (4.2.1) lib/sprockets/bundle.rb:31:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/base.rb:81:in `find_asset'
sprockets (4.2.1) lib/sprockets/base.rb:88:in `find_all_linked_assets'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `each'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `to_a'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker' 

EDITED TO ADD THIS:

I found a coffeescript file that was changed, although I don't think I did it knowingly. I do not know CoffeeScript. I pulled the contents of the changed file from git. Not sure if the indenting shown in git is what it actually was. Would someone who knows CoffeeScript know how it should be formatted?

# app/assets/javascript/packs/application.coffee

setup = ->

  $(document).foundation();

$ ->

  console.log "Loading page...!  " + Date.now()%10000

  setup()

  document.addEventListener "turbolinks:load", () ->

  console.log "turbolinks:load "  + Date.now()%10000

    setup()

Solution

  • This error means your COFFEE-SCRIPT file has an incorrect indentation.

    CoffeeScript uses indentations to open/close functions, so you cannot indent improperly.

    Best suggestion is to see which coffee file you most recently edited and start debugging.

    Visit https://coffeescript.org/#try and paste the code onto the left side.

    your coffeescript code error