gel-rb / gel

A modern gem manager: Gel is a lightweight alternative to Bundler

Home Page:https://gel.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gem already installed on first run should not fail with a non-zero error

omarsotillo opened this issue · comments

Already install gems should not fail after the first run with a non-zero error. This is happening with the case of ruby_parser. See dockerfile:

FROM ruby:2.6.4-alpine

RUN apk --no-cache update && apk add --update alpine-sdk tzdata linux-headers
    gem update --system && gem install gel && \
    apk add --update postgresql-client postgresql-dev && \
    apk add --update nodejs


RUN mkdir -p /app
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["rackup", "--host", "0.0.0.0", "-p", "3000"]

ADD Gemfile Gemfile.lock .ruby-version ./
RUN gel install --jobs 5

COPY . ./

The error is dispatched locally and in the pipeline(just trying to see time improvement in real environments branches):
image

Hi! Thanks for the report!

This error was intended as a safety mechanism (especially early in development), so the installer would not overwrite any existing files it wasn't expecting, in case that indicated the internal database had been corrupted (or worse, it was looking in the wrong place).

In this case, though, it seems to have surfaced a bug in handling of similarly-named files inside a gem: here, we're getting confused by ruby_parser's lib/ruby_lexer.rex and lib/ruby_lexer.rex.rb.

I think this line:

store.add_lib(spec.name, location, @files[reqp].map { |s| s.sub(loadable_file_types_re, "") })

probably needs to filter the @files[reqp] down to grep(loadable_file_types_re) -- we do want to register ruby_lexer.rex as a requireable path for lib/ruby_lexer.rex.rb, but there's no way to require lib/ruby_lexer.rex itself.

If you (or anyone else) are interested in trying for a PR, I think the easiest way to add a test is probably to add ruby_parser to FIXTURE_GEMS. Some things like this would be better tested in isolation, but creating artificial gems seems like a lot more work.

Hey! @matthewd thanks for the response 👍

I'll take a look into it this weekend and onboard myself into the code a little. I will provide a fix and open the PR after that if someone did not :)

Thanks again (and for the gem)

Fixed by #115 ❤️