Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDS API Adapters fails to build #389

Closed
huwd opened this issue Aug 17, 2020 · 5 comments · Fixed by #396 or #406
Closed

GDS API Adapters fails to build #389

huwd opened this issue Aug 17, 2020 · 5 comments · Fixed by #396 or #406
Assignees

Comments

@huwd
Copy link
Member

huwd commented Aug 17, 2020

In this episode of Will it build:

Steps to reproduce

Join our plucky cast as they attempt to run:
make gds-api-adapters

Stack trace

And encounter the mysterious case of the missing Argument

/home/huw/govuk/govuk-docker/exe/govuk-docker run gds-api-adapters-lite rbenv install -s || (/home/huw/govuk/govuk-docker/exe/govuk-docker build --no-cache gds-api-adapters-lite; /home/huw/govuk/govuk-docker/exe/govuk-docker run gds-api-adapters-lite rbenv install -s)
docker-compose -f [...] run gds-api-adapters-lite rbenv install -s
/home/huw/govuk/govuk-docker/exe/govuk-docker run gds-api-adapters-lite sh -c 'gem install --conservative --no-document bundler -v $(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -1)'
docker-compose -f [...] run gds-api-adapters-lite sh -c gem install --conservative --no-document bundler -v $(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -1)
grep: Gemfile.lock: No such file or directory
ERROR:  While executing gem ... (OptionParser::MissingArgument)
    missing argument: -v
make: *** [Makefile:41: bundle-gds-api-adapters] Error 1

Also note

So... I suspect this is because the central Makefile has an expectation there'll be a Gemfile.lock coming with each package.
But in this case gds-api-adapters appears to be a gem itself.

So i guess in this case something more custom in the makefile, (or perhaps another task that focuses on the steps for Gems?) is the route?

@huwd huwd self-assigned this Aug 17, 2020
@kevindew
Copy link
Member

Oh interesting, I guess that happens with most gems since they'll often not have a Gemfile.lock on initial cloning. I guess the options we'd want to consider is either only running gem install bundler when Gemfile.lock exists or to just install the latest version of bundler in that scenario. I think the former situation should be fine since Ruby bundles bundler in recent versions. Do you know if this commands works for you if you just comment out that line?

@huwd
Copy link
Member Author

huwd commented Aug 18, 2020

Yep that works great if i comment that out.
So... humm we could either wrap this in an If statement, so IF there's a Gemfile.lock then run this command?
Or is there a more graceful failure state? Like if you run it and fail then continue?

my bash fu is a little lacking, if you had any starting point on syntax i'd be happy to go test until there's something PR-able?

@huwd
Copy link
Member Author

huwd commented Aug 19, 2020

Humm or... perhaps we should have the assumption that every repo should have a Gemfile.lock - unless it has a gemspec file?

@kevindew
Copy link
Member

Sure, for lack of a more elegant idea this should do the trick: if [ -f Gemfile.lock ]; then gem install --conservative --no-document bundler -v $$(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -1); fi

It feels somewhat more complex to involve gemspecs in the equation if we can avoid it

huwd added a commit that referenced this issue Sep 9, 2020
A response to issue #389, govuk-docker contains some gems that are
needed to use with other applications that tend not to have a
Gemfile.lock when initialy cloned. This was causing make (eg. `make
gds-api-adapters`) to fail.

Here we make the depdency explicit and skip the step if no Gemfile.lock
exists, a step that hasn't proved disruptive to using the adapters in
other applications.
@huwd
Copy link
Member Author

huwd commented Sep 9, 2020

Sorry had some time off and only just got back on this!
https://github.com/alphagov/govuk-docker/compare/fix-gds-api-adapters?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants