From cab64e17cf8f35814256570b8aa1d5e5b21722f0 Mon Sep 17 00:00:00 2001 From: Sebastian Fiedlschuster Date: Tue, 1 Feb 2022 22:23:15 +0000 Subject: [PATCH 1/3] configure backtrace silencers for dummy app - Show the matestack backtrace, which is hidden by default by the backtrace silencer, in the terminal - Remove the docker directory `/app/` from the beginning of the paths; this allows, for example, to use iTerm's semantic-history feature, which is useful for debugging https://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html https://github.com/rails/rails/blob/main/activesupport/lib/active_support/backtrace_cleaner.rb --- .../config/initializers/backtrace_silencers.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/dummy/config/initializers/backtrace_silencers.rb b/spec/dummy/config/initializers/backtrace_silencers.rb index 59385cdf3..8fa57b9dd 100644 --- a/spec/dummy/config/initializers/backtrace_silencers.rb +++ b/spec/dummy/config/initializers/backtrace_silencers.rb @@ -1,7 +1,13 @@ # Be sure to restart your server when you modify this file. -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# https://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html +# https://github.com/rails/rails/blob/main/activesupport/lib/active_support/backtrace_cleaner.rb -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# Show only stacktrace of matestack or the dummy app and not the other gems +Rails.backtrace_cleaner.remove_silencers! +Rails.backtrace_cleaner.add_silencer { |line| line.include? "/usr/local/bundle/gems" } + +# Remove docker-path prefix "/app/" from paths to allow advanced terminal features +# like iTerm's "semantic history" which would be broken by the docker path. +Rails.backtrace_cleaner.remove_filters! +Rails.backtrace_cleaner.add_filter { |line| line.gsub(/^\/app\//, '') } From 0e868d5196eb840f177736a6356fb58c74d0b3c1 Mon Sep 17 00:00:00 2001 From: Sebastian Fiedlschuster Date: Tue, 1 Feb 2022 23:38:48 +0100 Subject: [PATCH 2/3] Gemfile: add the `pry` gems to the `development` group in order to allow `binding.pry` in development https://github.com/pry/pry https://github.com/pry/pry-rails https://github.com/deivid-rodriguez/pry-byebug Hint: When using this with docker, you need to attach to the rails-server docker container to use the interactive pry session: docker-compose up dummy docker attach matestack-ui-core_dummy_1 --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a7d3b66d7..90a2c109d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,11 +23,11 @@ group :development, :test do gem 'simplecov', require: false, group: :test gem 'byebug' gem 'webmock' + gem 'pry-rails' + gem 'pry-byebug' end group :test do - gem 'pry-rails' - gem 'pry-byebug' gem "generator_spec" # gem "rspec-retry" # repeating flaky tests # gem "rspec-wait", "~> 0.0.9" From e1514ad163fb60e78c3b1cf021fadddd18e4e77b Mon Sep 17 00:00:00 2001 From: Sebastian Fiedlschuster Date: Sat, 5 Feb 2022 18:20:59 +0100 Subject: [PATCH 3/3] fixing issue with `pry` with busybox `less` `pry` requires a newer version of `less` to display long results properly. https://github.com/pry/pry/issues/1248 --- Dockerfile.dev | 3 +++ Dockerfile.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Dockerfile.dev b/Dockerfile.dev index 8b7e062d9..8a2e0ceb5 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,6 +6,9 @@ RUN apk update --no-cache && \ apk add build-base postgresql-dev git nodejs yarn tzdata bash sqlite-dev npm && \ mkdir -p /app +# https://github.com/pry/pry/issues/1248 +RUN apk --update add less + WORKDIR /app COPY ./lib/ /app/lib/ diff --git a/Dockerfile.test b/Dockerfile.test index ac7beb300..1d2d6fd40 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -6,6 +6,9 @@ RUN apk update --no-cache && \ apk add build-base postgresql-dev git nodejs yarn tzdata bash sqlite-dev npm && \ mkdir -p /app +# https://github.com/pry/pry/issues/1248 +RUN apk --update add less + WORKDIR /app COPY ./lib/ /app/lib/