nix-community / bundix

Generates a Nix expression for your Bundler-managed application. [maintainer=@manveru]
163 stars 55 forks source link

Bundix parses stderr output of `nix-instantiate` causing parse errors when `nix` emits a warning #74

Open arianvp opened 4 years ago

arianvp commented 4 years ago

When bundix parses out output of nix-instantiate it reads both stderr and stdout. If nix logs an error message, then bundix crashes.

Originally found due to some bug in Nix https://github.com/NixOS/nix/issues/3784 but bundix shouldn't fail parsing when Nix logs something to stderr.

How to reproduce

  1. Make a Gemfile with a gem
  2. run bundix -m
  3. run bundix -m again
  4. Add a config option that isn't supported in nix to your nix conf
  5. now you'll see many warning: unknown setting 'foo'
  6. Bundix crashes when parsing the gemset.nix
warning: unknown setting 'sandbox-fallback'
Fetching gem metadata from https://rubygems.org/.........
Writing lockfile to /home/arian/Projects/minvws/nl-covid19-notification-app-community-website/Gemfile.lock
warning: unknown setting 'sandbox-fallback'
Fetching gem metadata from https://rubygems.org/.........
Fetching concurrent-ruby 1.1.6
Fetching i18n 0.9.5
Fetching minitest 5.14.1
Fetching thread_safe 0.3.6
Fetching tzinfo 1.2.7
Fetching zeitwerk 2.3.1
Fetching activesupport 6.0.3.2
Fetching public_suffix 3.1.1
Fetching addressable 2.7.0
Using bundler 1.17.3
Fetching coffee-script-source 1.11.1
Fetching execjs 2.7.0
Fetching coffee-script 2.4.1
Fetching colorator 1.1.0
Fetching ruby-enum 0.8.0
Fetching commonmarker 0.17.13
Fetching dnsruby 1.61.3
Fetching eventmachine 1.2.7
Fetching http_parser.rb 0.6.0
Fetching em-websocket 0.5.1
Fetching ffi 1.13.1
Fetching ethon 0.12.0
Fetching multipart-post 2.1.1
Fetching faraday 1.0.1
Fetching forwardable-extended 2.6.0
Fetching gemoji 3.0.1
Fetching sawyer 0.8.2
Fetching octokit 4.18.0
Fetching typhoeus 1.4.0
Fetching github-pages-health-check 1.16.1
Fetching rb-fsevent 0.10.4
Fetching rb-inotify 0.10.1
Fetching sass-listen 4.0.0
Fetching sass 3.7.4
Fetching jekyll-sass-converter 1.5.2
Fetching listen 3.2.1
Fetching jekyll-watch 2.2.1
Fetching kramdown 1.17.0
Fetching liquid 4.0.3
Fetching mercenary 0.3.6
Fetching pathutil 0.16.2
Fetching rouge 3.19.0
Fetching safe_yaml 1.0.5
Fetching jekyll 3.8.7
Fetching jekyll-avatar 0.7.0
Fetching jekyll-coffeescript 1.1.1
Fetching jekyll-commonmark 1.3.1
Fetching jekyll-commonmark-ghpages 0.1.6
Fetching jekyll-default-layout 0.1.4
Fetching jekyll-feed 0.13.0
Fetching jekyll-gist 1.5.0
Fetching jekyll-github-metadata 2.13.0
Fetching mini_portile2 2.4.0
Fetching nokogiri 1.10.9
Fetching html-pipeline 2.13.0
Fetching jekyll-mentions 1.5.1
Fetching jekyll-optional-front-matter 0.3.2
Fetching jekyll-paginate 1.1.0
Fetching jekyll-readme-index 0.3.0
Fetching jekyll-redirect-from 0.15.0
Fetching jekyll-relative-links 0.6.1
Fetching rubyzip 2.3.0
Fetching jekyll-remote-theme 0.4.1
Fetching jekyll-seo-tag 2.6.1
Fetching jekyll-sitemap 1.4.0
Fetching jekyll-swiss 1.0.0
Fetching jekyll-theme-architect 0.1.1
Fetching jekyll-theme-cayman 0.1.1
Fetching jekyll-theme-dinky 0.1.1
Fetching jekyll-theme-hacker 0.1.1
Fetching jekyll-theme-leap-day 0.1.1
Fetching jekyll-theme-merlot 0.1.1
Fetching jekyll-theme-midnight 0.1.1
Fetching jekyll-theme-minimal 0.1.1
Fetching jekyll-theme-modernist 0.1.1
Fetching jekyll-theme-primer 0.5.4
Fetching jekyll-theme-slate 0.1.1
Fetching jekyll-theme-tactile 0.1.1
Fetching jekyll-theme-time-machine 0.1.1
Fetching jekyll-titles-from-headings 0.5.3
Fetching jemoji 0.11.1
Fetching minima 2.5.1
Fetching unicode-display_width 1.7.0
Fetching terminal-table 1.8.0
Fetching github-pages 206
Fetching jekyll-multiple-languages-plugin 1.7.0
Bundle complete! 2 Gemfile dependencies, 86 gems now installed.
Bundled gems are installed into `./vendor/bundle`
Post-install message from dnsruby:
Installing dnsruby...
  For issues and source code: https://github.com/alexdalitz/dnsruby
  For general discussion (please tell us how you use dnsruby): https://groups.google.com/forum/#!forum/dnsruby
Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Updating files in vendor/cache
  * concurrent-ruby-1.1.6.gem
  * i18n-0.9.5.gem
  * minitest-5.14.1.gem
  * thread_safe-0.3.6.gem
  * tzinfo-1.2.7.gem
  * zeitwerk-2.3.1.gem
  * activesupport-6.0.3.2.gem
  * public_suffix-3.1.1.gem
  * addressable-2.7.0.gem
  * coffee-script-source-1.11.1.gem
  * execjs-2.7.0.gem
  * coffee-script-2.4.1.gem
  * colorator-1.1.0.gem
  * ruby-enum-0.8.0.gem
  * commonmarker-0.17.13.gem
  * dnsruby-1.61.3.gem
  * eventmachine-1.2.7.gem
  * http_parser.rb-0.6.0.gem
  * em-websocket-0.5.1.gem
  * ffi-1.13.1.gem
  * ethon-0.12.0.gem
  * multipart-post-2.1.1.gem
  * faraday-1.0.1.gem
  * forwardable-extended-2.6.0.gem
  * gemoji-3.0.1.gem
  * sawyer-0.8.2.gem
  * octokit-4.18.0.gem
  * typhoeus-1.4.0.gem
  * github-pages-health-check-1.16.1.gem
  * rb-fsevent-0.10.4.gem
  * rb-inotify-0.10.1.gem
  * sass-listen-4.0.0.gem
  * sass-3.7.4.gem
  * jekyll-sass-converter-1.5.2.gem
  * listen-3.2.1.gem
  * jekyll-watch-2.2.1.gem
  * kramdown-1.17.0.gem
  * liquid-4.0.3.gem
  * mercenary-0.3.6.gem
  * pathutil-0.16.2.gem
  * rouge-3.19.0.gem
  * safe_yaml-1.0.5.gem
  * jekyll-3.8.7.gem
  * jekyll-avatar-0.7.0.gem
  * jekyll-coffeescript-1.1.1.gem
  * jekyll-commonmark-1.3.1.gem
  * jekyll-commonmark-ghpages-0.1.6.gem
  * jekyll-default-layout-0.1.4.gem
  * jekyll-feed-0.13.0.gem
  * jekyll-gist-1.5.0.gem
  * jekyll-github-metadata-2.13.0.gem
  * mini_portile2-2.4.0.gem
  * nokogiri-1.10.9.gem
  * html-pipeline-2.13.0.gem
  * jekyll-mentions-1.5.1.gem
  * jekyll-optional-front-matter-0.3.2.gem
  * jekyll-paginate-1.1.0.gem
  * jekyll-readme-index-0.3.0.gem
  * jekyll-redirect-from-0.15.0.gem
  * jekyll-relative-links-0.6.1.gem
  * rubyzip-2.3.0.gem
  * jekyll-remote-theme-0.4.1.gem
  * jekyll-seo-tag-2.6.1.gem
  * jekyll-sitemap-1.4.0.gem
  * jekyll-swiss-1.0.0.gem
  * jekyll-theme-architect-0.1.1.gem
  * jekyll-theme-cayman-0.1.1.gem
  * jekyll-theme-dinky-0.1.1.gem
  * jekyll-theme-hacker-0.1.1.gem
  * jekyll-theme-leap-day-0.1.1.gem
  * jekyll-theme-merlot-0.1.1.gem
  * jekyll-theme-midnight-0.1.1.gem
  * jekyll-theme-minimal-0.1.1.gem
  * jekyll-theme-modernist-0.1.1.gem
  * jekyll-theme-primer-0.5.4.gem
  * jekyll-theme-slate-0.1.1.gem
  * jekyll-theme-tactile-0.1.1.gem
  * jekyll-theme-time-machine-0.1.1.gem
  * jekyll-titles-from-headings-0.5.3.gem
  * jemoji-0.11.1.gem
  * minima-2.5.1.gem
  * unicode-display_width-1.7.0.gem
  * terminal-table-1.8.0.gem
  * github-pages-206.gem
  * jekyll-multiple-languages-plugin-1.7.0.gem
Traceback (most recent call last):
        9: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/bin/.bundix-wrapped:18:in `<main>'
        8: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/bin/.bundix-wrapped:18:in `load'
        7: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/bin/bundix:5:in `<top (required)>'
        6: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/lib/bundix/commandline.rb:22:in `run'
        5: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/lib/bundix/commandline.rb:35:in `run'
        4: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/lib/bundix/commandline.rb:148:in `build_gemset'
        3: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/lib/bundix.rb:46:in `convert'
        2: from /nix/store/qqxgiziqpri256809rzn8rfyh01njsb8-bundix-2.4.1/lib/ruby/gems/2.5.0/gems/bundix-2.4.1/lib/bundix.rb:173:in `parse_gemset'
        1: from /nix/store/abd2zgz6vvmf9gxw5ra49ibqp1gs15c3-ruby-2.5.5/lib/ruby/2.5.0/json/common.rb:156:in `parse'
/nix/store/abd2zgz6vvmf9gxw5ra49ibqp1gs15c3-ruby-2.5.5/lib/ruby/2.5.0/json/common.rb:156:in `parse': 765: unexpected token at 'arning: unknown setting 'sandbox-fallback' (JSON::ParserError)
"{"activesupport":{"dependencies":["concurrent-ruby","i18n","minitest","tzinfo","zeitwerk"],"groups":["default","jekyll_plugins"],"platforms":[],"source":{"remotes":["https://rubygems.org"],"s