2

I'm trying to do this:

rake routes | less

but it is producing the following weird characters, and breaking less so that it won't search or respond properly. This is new and used to work for a couple years. Something on my system has changed and I don't know how to stop it or change it! How can I avoid this issue?

^[[1m^[[36mSQL (0.7ms)^[[0m  ^[[1mdescribe `roles_users`^[[0m                                                                                                                                               
  ^[[1m^[[35mSQL (0.9ms)^[[0m  describe `teams_users`
  ^[[1m^[[36mSQL (1.0ms)^[[0m  ^[[1mdescribe `instructors_media_clips`^[[0m
  ^[[1m^[[35mSQL (0.7ms)^[[0m  describe `collections_packs`
  ^[[1m^[[36mSQL (0.7ms)^[[0m  ^[[1mdescribe `lessons_songs`^[[0m
  ^[[1m^[[35mSQL (0.9ms)^[[0m  describe `media_clips_packs`
  ^[[1m^[[36mSQL (0.9ms)^[[0m  ^[[1mdescribe `instructors_media_clips`^[[0m
  ^[[1m^[[35mSQL (1.0ms)^[[0m  describe `related_media_clips`
  ^[[1m^[[36mSQL (0.7ms)^[[0m  ^[[1mdescribe `lesson_instructors`^[[0m
  ^[[1m^[[35mSQL (0.8ms)^[[0m  describe `collections_packs`
  ^[[1m^[[36mSQL (0.6ms)^[[0m  ^[[1mdescribe `media_clips_packs`^[[0m
  ^[[1m^[[35mSQL (0.8ms)^[[0m  describe `roles_users`
  ^[[1m^[[36mSQL (0.7ms)^[[0m  ^[[1mdescribe `lessons_songs`^[[0m
  ^[[1m^[[35mSQL (0.8ms)^[[0m  describe `teams_users`
                  admin_admin_main GET    /admin/admin/main(.:format)                   {:controller=>"admin", :action=>"index"}
                  new_user_session GET    /:locale/members/sign_in(.:format)            {:controller=>"sessions", :action=>"new"}
                      user_session POST   /:locale/members/sign_in(.:format)            {:controller=>"sessions", :action=>"create"}
              destroy_user_session GET    /:locale/members/sign_out(.:format)           {:controller=>"sessions", :action=>"destroy"}
                     user_password POST   /:locale/members/password(.:format)           {:controller=>"devise/passwords", :action=>"create"}
                 new_user_password GET    /:locale/members/password/new(.:format)       {:controller=>"devise/passwords", :action=>"new"}
                edit_user_password GET    /:locale/members/password/edit(.:format)      {:controller=>"devise/passwords", :action=>"edit"}
                                   PUT    /:locale/members/password(.:format)           {:controller=>"devise/passwords", :action=>"update"}
          cancel_user_registration GET    /:locale/members/cancel(.:format)             {:controller=>"registrations", :action=>"cancel"}
                 user_registration POST   /:locale/members(.:format)                    {:controller=>"registrations", :action=>"create"}
             new_user_registration GET    /:locale/members/sign_up(.:format)            {:controller=>"registrations", :action=>"new"}
            edit_user_registration GET    /:locale/members/edit(.:format)               {:controller=>"registrations", :action=>"edit"}
                                   PUT    /:locale/members(.:format)                    {:controller=>"registrations", :action=>"update"}
                                   DELETE /:locale/members(.:format)                    {:controller=>"registrations", :action=>"destroy"}
                     profile_users GET    /:locale/users/profile(.:format)              {:controller=>"users", :action=>"profile"}
                             users GET    /:locale/users(.:format)                      {:controller=>"users", :action=>"index"}
                                   POST   /:locale/users(.:format)                      {:controller=>"users", :action=>"create"}
                          new_user GET    /:locale/users/new(.:format)                  {:controller=>"users", :action=>"new"}
                         edit_user GET    /:locale/users/:id/edit(.:format)             {:controller=>"users", :action=>"edit"}
                              user GET    /:locale/users/:id(.:format)                  {:controller=>"users", :action=>"show"}
                                   PUT    /:locale/users/:id(.:format)                  {:controller=>"users", :action=>"update"}
                                   DELETE /:locale/users/:id(.:format)                  {:controller=>"users", :action=>"destroy"}
                             roles GET    /:locale/roles(.:format)                      {:controller=>"roles", :action=>"index"}
                                   POST   /:locale/roles(.:format)                      {:controller=>"roles", :action=>"create"}
xhienne
  • 5,738
  • 1
  • 15
  • 34
pixelearth
  • 13,674
  • 10
  • 62
  • 110

2 Answers2

1

Those look like ANSI color escape sequences. It's as if less is not interpreting the sequences correctly. You're sure you're not using any options with less? Maybe there's some option like less -R or less --RAW-CONTROL-CHARS. I admit I don't know a whole lot about ANSI color escape sequences.

Jared Beck
  • 16,796
  • 9
  • 72
  • 97
  • Jared: I think you're right, I'm using a gem called Hirb, that shows all db queries the console, but it outputs them in color. I wonder how I can tell `less` to ignore those sequences. Definitely not SPECIFICALLY asking less to display the chars tho... – pixelearth Aug 29 '11 at 01:41
  • by using -R or -r tho I get the sequences to actually appear in color in `less`, but my commands to less are mostly ignored and misinterpreted still. For example my j command (to move down) just prints a 'j' – pixelearth Aug 29 '11 at 01:49
  • Don't know if this may help, but if you are in a console, without a mouse, you can always use Shift+PageUp/PageDown to scroll a few pages – Zequez Aug 29 '11 at 02:44
0

Jared is correct to say you need to use less -R to interpret the color sequences.

In terms of losing control of less's navigation, I don't think it's caused by rake, but by something in rails trying to read from STDIN.

To work around the issue, redirect STDIN:

rake routes </dev/null | less
Kelvin
  • 20,119
  • 3
  • 60
  • 68