LoginSignup
16
7

More than 3 years have passed since last update.

【Rails on Docker】Modelの全件取得(all)ができなくなって困った

Posted at

Problem

rails consoleでとあるモデルをallで全件取得しようとしたところ以下のエラーに遭遇。

[1] pry(main)> User.all
  Member Load (9.3ms)  SELECT "users".* FROM "users" ORDER BY "users"."created_at" ASC
less: unrecognized option: X
BusyBox v1.30.1 (2019-10-26 11:23:07 UTC) multi-call binary.

Usage: less [-EFIMmNSRh~] [FILE]...
  1 FROM ruby:2.6.5-alpine3.10

View FILE (or stdin) one screenful at a time

    -E  Quit once the end of a file is reached
    -F  Quit if entire file fits on first screen
    -I  Ignore case in all searches
    -M,-m   Display status line with line numbers
        and percentage through the file
    -N  Prefix line number to each line
    -S  Truncate long lines
    -R  Remove color escape codes in input
    -~  Suppress ~s displayed past EOF

なんかできるモデルとできないモデルがあって困った。
なんとなく件数が少ないモデルは見えるけど多いモデルはエラーになる。

Trouble Shooting

結論からいえば、Alpine LinuxをベースとしてDocker上でRailsを動かしていたのですが、Alpine Linuxにはlessが標準装備されていないためこうなるらしい。
hirbとか使っているからpager機能がついているのかな...その時less使ってるのかな...
まぁとりあえず復旧だ。

Dockerfile
RUN apk add --update --no-cache less
docker-compose build

エラー出なくなった。

Reference

docker alpineでpryデバッグ中に less -Rが立ち上がらない - Qiita

16
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
7