Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Figure out Travis CI failures #16

Closed
mbland opened this issue Feb 3, 2016 · 6 comments · Fixed by #17 or #18
Closed

Figure out Travis CI failures #16

mbland opened this issue Feb 3, 2016 · 6 comments · Fixed by #17 or #18
Labels

Comments

@mbland
Copy link
Contributor

mbland commented Feb 3, 2016

Travis has started throwing errors for ./go build:

https://travis-ci.org/18F/web-design-standards/builds/106562512
https://travis-ci.org/18F/web-design-standards/builds/106737058#L247

$ bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
$ ./go build
/home/travis/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 45 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/travis/build/18F/web-design-standards/vendor/bundle/ruby/2.2.0', execute `gem env` for more information
    from /home/travis/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
    from /home/travis/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /home/travis/.rvm/gems/ruby-2.2.3/bin/bundle:22:in `<main>'
    from /home/travis/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
    from /home/travis/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'

travis-ci/travis-ci#4536 references this problem, which I think has to do with the --path argument and bundler itself not being in the BUNDLER_PATH.

Also: https://docs.travis-ci.com/user/caching/#Bundler

cc: @juliaelman @harrisj @afeld @rogeruiz

@mbland
Copy link
Contributor Author

mbland commented Feb 23, 2016

The remedy per 18F/team-api.18f.gov#194 appears to be adding this to .travis.yml:

before_install:
- export GEM_HOME=$PWD/vendor/bundle/ruby/2.2.0
- gem install bundler

@afeld
Copy link
Contributor

afeld commented Feb 23, 2016

😒

@mbland
Copy link
Contributor Author

mbland commented Feb 23, 2016

Actually, @jcscottiii figured out in 18F/knowledge-sharing-toolkit#3 that this is actually all that's needed:

install:
  - echo "no install steps needed"

@mbland
Copy link
Contributor Author

mbland commented Feb 25, 2016

I understand why this is happening now (thanks to my work on 18F/knowledge-sharing-toolkit, where I hit the same issue trying to Dockerize 18F/team-api-server).

When the system invokes bundler install --path=..., in addition to creating the directory structure specified by --path=..., it also creates a .bundle/config file that contains:

---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'

When ./go build runs, it calls GoScript.build_jekyll from go_script/go.rb. That command executes JEKYLL_BUILD_CMD, defined as:

JEKYLL_BUILD_CMD = 'bundle exec jekyll build --trace'

So when executing the ./go script, require 'bundler/setup' reads .bundle/config and sets the gem path accordingly. Then when JEKYLL_BUILD_COMMAND runs, bundle can't find its own implementation, since the gem path is now vendor/bundle and shared gems are disabled. From the bottom of this stack trace:

team-api@e094cab62656:/usr/local/18f/team-api/team-api.18f.gov$ ./go build
Building internal version...
/usr/local/18f/rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'bundler' (>= 0.a) among 46 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/usr/local/18f/team-api/team-api.18f.gov/vendor/bundle/ruby/2.3.0', execute `gem env` for more information
        from /usr/local/18f/rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
        from /usr/local/18f/rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
        from /usr/local/18f/rbenv/versions/2.3.0/bin/bundle:22:in `<main>'

we can see that /usr/local/18f/rbenv/versions/2.3.0/bin/bundle:22 invokes:

gem 'bundler', version

There are two workarounds. One, set BUNDLE_DISABLE_SHARED_GEMS to false. Two, make sure to do the gem install bundler bit as mentioned above (re: 18F/team-api.18f.gov#194) before invoking ./go build.

The "real" solution, however, is to make go_script detect when .bundle/config is present and install bundler as necessary.

@mbland
Copy link
Contributor Author

mbland commented Feb 25, 2016

Or, we can remove the bundle exec from the JEKYLL_BUILD_COMMAND, since the ./go script itself calls require 'bundler/setup' first thing. I'll try that.

mbland pushed a commit that referenced this issue Feb 25, 2016
Per #16, Travis started generating these.
mbland pushed a commit that referenced this issue Feb 25, 2016
See #16 for details. Basically, since the `./go` script should already invoke
`require 'bundler/setup'`, running Jekyll with `bundle exec` proves
unnecessary. The test_bundler_with_path_argument test case recreates the
original failure faithfully, and validates the fix.
mbland pushed a commit that referenced this issue Feb 26, 2016
Contains fix from #17 to fix Travis build failures reported in #16.
mbland pushed a commit that referenced this issue Feb 27, 2016
Closes #16.

This change now ensures that _only_ the RUBYOPT variable gets filtered out
of the child process environment (as introduced in #10). Most of the files
here are for the new Jekyll test site, cribbed from the
jekyll_pages_api_search gem tests, but with the jekyll_pages_api_search
components stripped out.

Removing `bundle exec` from JEKYLL_BUILD_CMD in #17 meant that BUNDLE_BIN_PATH
and BUNDLE_GEMFILE weren't set for the Jekyll child process. Therefore, when
Jekyll tried to load a gem from the :jekyll_plugins group, it couldn't find
it. From https://travis-ci.org/18F/before-you-ship/builds/112281551:

1.22s$ ./go ci_test
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in
`rescue in block (2 levels) in require': There was an error while trying to
load the gem 'guides_style_18f'. (Bundler::GemRequireError)
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in
`block (2 levels) in require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`each'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`block in require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`each'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler.rb:99:in
`require'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/gems/jekyll-3.1.2/lib/jekyll/plugin_manager.rb:34:in
`require_from_bundler'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/gems/jekyll-3.1.2/bin/jekyll:9:in
`<top (required)>'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/bin/jekyll:23:in
`load'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/bin/jekyll:23:in
`<main>'

The tests added in #17 didn't catch this because they only tried to execute
the `./go` script rather than build a Jekyll site containing a plugin. The
updated tests, which now build a Jekyll site with the guides_style_18f plugin,
both reproduce the above error and verify its fix.
@mbland
Copy link
Contributor Author

mbland commented Feb 27, 2016

Turns out #17 introduced a new issue, and not just a Travis issue, but a general Jekyll build issue. #18 is now out to resolve this issue.

Removing bundle exec from JEKYLL_BUILD_CMD in that pull request meant that BUNDLE_BIN_PATH and BUNDLE_GEMFILE weren't set for the Jekyll child process. Therefore, when Jekyll tried to load a gem from the :jekyll_plugins group, it couldn't find it. From https://travis-ci.org/18F/before-you-ship/builds/112281551:

$ ./go ci_test
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in
`rescue in block (2 levels) in require': There was an error while trying to
load the gem 'guides_style_18f'. (Bundler::GemRequireError)
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in
`block (2 levels) in require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`each'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`block in require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`each'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`require'
        from
/home/travis/.rvm/gems/ruby-2.2.4@global/gems/bundler-1.11.2/lib/bundler.rb:99:in
`require'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/gems/jekyll-3.1.2/lib/jekyll/plugin_manager.rb:34:in
`require_from_bundler'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/gems/jekyll-3.1.2/bin/jekyll:9:in
`<top (required)>'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/bin/jekyll:23:in
`load'
        from
/home/travis/build/18F/before-you-ship/vendor/bundle/ruby/2.2.0/bin/jekyll:23:in
`<main>'

The tests added in #17 didn't catch this because they only tried to execute the ./go script rather than build a Jekyll site containing a plugin. The updated tests, which now build a Jekyll site with the guides_style_18f plugin, both reproduce the above error and verify its fix.

@mbland mbland reopened this Feb 27, 2016
@afeld afeld closed this as completed in #18 Feb 29, 2016
@afeld afeld unassigned mbland Mar 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants