um icon indicating copy to clipboard operation
um copied to clipboard

Use Etc.getpwuid.name instead of Etc.getlogin

Open b-ggs opened this issue 5 years ago • 0 comments

This fix is specifically for running um inside a Docker container.

For some reason Etc.getlogin returns nil when inside a Docker container. I'm not sure of the reason why that's so, but some light searching pointed to recommendations to use Etc.getpwuid instead of Etc.getlogin anyway. (https://www.rubydoc.info/stdlib/etc/Etc.getlogin)

Reproduction steps:

Dockerfile

FROM ruby:2.6.5-buster

RUN git clone https://github.com/sinclairtarget/um.git \
  && cd um \
  && gem build *.gemspec \
  && gem install um*.gem

CMD ["um", "list"] 

Building and running that produces this output:

/usr/local/bundle/gems/um-4.2.0/lib/um/umconfig.rb:113:in `+': no implicit conversion of nil into String (TypeError)
        from /usr/local/bundle/gems/um-4.2.0/lib/um/umconfig.rb:113:in `write_pages_directory'
        from /usr/local/bundle/gems/um-4.2.0/lib/um/umconfig.rb:78:in `source'
        from /usr/local/bundle/gems/um-4.2.0/libexec/um-list.rb:18:in `<main>'

With patch:

Dockerfile

FROM ruby:2.6.5-buster

RUN git clone --single-branch --branch b-ggs/getpwuid https://github.com/b-ggs/um.git \
  && cd um \
  && gem build *.gemspec \
  && gem install um*.gem

CMD ["um", "list"]

Now, running that presents the expected output:

No pages found for topic "shell."

b-ggs avatar Dec 22 '19 20:12 b-ggs