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

vagrant: remove unused vendored Gemfile{,.lock} #47519

Merged
merged 1 commit into from Oct 5, 2018

Conversation

aneeshusa
Copy link
Contributor

Motivation for this change

Coming off of discussion on #47310.

I originally tried to use the Gemfile direct from the vagrant repo, but that uses gemspec to include dependencies. Our ruby infrastructure doesn't support gemspec right now, and it would be painful to support, as the vagrant.spec is dynamic and requires files from the Vagrant git repo to exist, all for metadata that we don't care about.

I'm no Ruby expert and the current vagrant setup is definitely a hack (it should probably use bundlerApp for example), but it manages to avoid bundler blowing up at runtime when it tries to validate the Gemfile/Gemfile.lock and don't involve too much manual effort at version update time. Since the Gemfile/Gemfile.lock don't seem to matter, just set them to empty files, as vagrant should only be used as an executable and not a library anyways.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

cc @Mic92 @alyssais

@aneeshusa
Copy link
Contributor Author

Also cc @zimbatm @cstrahan as folks who might be able to provide some Ruby expertise/insight.

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/fqm2x6kiay1q4vg7pqp4wp17bdijlyc3-bash-4.4-p23/bin/bash"
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/provisioners/salt/bootstrap-salt.sh: interpreter directive changed from "/bin/sh -" to "/nix/store/fqm2x6kiay1q4vg7pqp4wp17bdijlyc3-bash-4.4-p23/bin/sh -"
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/hosts/darwin/scripts/install_virtualbox.sh: interpreter directive changed from "/bin/bash" to "/nix/store/fqm2x6kiay1q4vg7pqp4wp17bdijlyc3-bash-4.4-p23/bin/bash"
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant.orig: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/w2qgcck5ams1h0d5ydmaz8yfq4c1az87-ruby-2.5.1/bin/ruby"
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/w2qgcck5ams1h0d5ydmaz8yfq4c1az87-ruby-2.5.1/bin/ruby"
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/.runner.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/fqm2x6kiay1q4vg7pqp4wp17bdijlyc3-bash-4.4-p23/bin/bash"
checking for references to /build in /nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2...
running install tests
Vagrant smoke check passed
/nix/store/gryk5wf927w8nif4h6v9a1jb607s8ck5-vagrant-2.1.2

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/7s5p6cwgz63pp1wgln9f7bg7sgy5jyrm-ruby-2.5.1/bin/ruby"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/provisioners/salt/bootstrap-salt.sh: interpreter directive changed from "/bin/sh -" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/sh -"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/hosts/darwin/scripts/install_virtualbox.sh: interpreter directive changed from "/bin/bash" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/bash"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/bash"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_www.sh: interpreter directive changed from "/bin/bash" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/bash"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_docs.sh: interpreter directive changed from "/bin/bash" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/bash"
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/.runner.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/z2pc6bbx9d1mwwahnds31a7nlvjbi9zr-bash-4.4-p23/bin/bash"
running install tests
Vagrant smoke check passed
/nix/store/r3sanf786fbzy9v0kvgja71nm4jlidmg-vagrant-2.1.2

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant.orig: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/42lf7caji1bykgrzmf22a58sqyb9knjj-ruby-2.5.1/bin/ruby"
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/42lf7caji1bykgrzmf22a58sqyb9knjj-ruby-2.5.1/bin/ruby"
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/.runner.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/czx8vkrb9jdgjyz8qfksh10vrnqa723l-bash-4.4-p23/bin/bash"
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_docs.sh: interpreter directive changed from "/bin/bash" to "/nix/store/czx8vkrb9jdgjyz8qfksh10vrnqa723l-bash-4.4-p23/bin/bash"
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_www.sh: interpreter directive changed from "/bin/bash" to "/nix/store/czx8vkrb9jdgjyz8qfksh10vrnqa723l-bash-4.4-p23/bin/bash"
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/czx8vkrb9jdgjyz8qfksh10vrnqa723l-bash-4.4-p23/bin/bash"
checking for references to /build in /nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2...
running install tests
Vagrant smoke check passed
/nix/store/s6wnizkdcq6jyjzqnjg5v5pdi2cxb0mj-vagrant-2.1.2

inherit ruby;
gemdir = ./.;
gemfile = writeText "Gemfile" "";
lockfile = writeText "Gemfile.lock" "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this works because bundler isn’t actually used at runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either that, or it does look at runtime but it accepts empty files 🤷‍♂️

@@ -0,0 +1,2 @@
/Gemfile
/Gemfile.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would these files end up here? (Just wondering why they need to be ignored)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the update script this would be become unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally the bundix workflow involves copying the Gemfile and Gemfile.lock into nixpkgs, however vagrant is a bit special. Since we're using empty files for those two, copying them into nixpkgs does nothing, so this was meant to ease the workflow for someone who is used to the standard bundix workflow.

This isn't necessary, but I thought it would be nice to have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the files showing up in the diff would be enough indication. Putting files somebody might accidentally copy into the repo in the gitignore seems like quite a can of worms to open :P

@Mic92
Copy link
Member

Mic92 commented Sep 29, 2018

I wrote this update script (update-gemset.sh) to generate a new gemset:

  #!/usr/bin/env nix-shell
  #!nix-shell -p ruby.devEnv bash -i bash
  set -exu
  temp=$(mktemp -d)
  function finish {
    rm -rf "$temp"
  }
  trap finish EXIT
  NIXPKGS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"/../../../..
  SRC=$(nix-build --no-out-link "$NIXPKGS" -A vagrant.src)
  tar -xvf "$SRC" -C "$temp"
  (cd "$temp"/vagrant-* && bundle && bundix .)
  cp "$temp"/vagrant-*/gemset.nix .

@aneeshusa
Copy link
Contributor Author

That script seems like it would work but I'd rather not vendor that in as it's essentially the standard bundix workflow minus the "copy over Gemfile and Gemfile.lock".
I actually update vagrant versions by hand usually since I only maintain a few packages.

@@ -404,7 +404,7 @@
source = {
fetchSubmodules = false;
rev = "9413ab298407114528766efefd1fb1ff24589636";
sha256 = "1z77m3p6x82hipa7y4i71zafy0rdfajw2vhqdxczjmrlwp0pvisl";
sha256 = "0mb0cxrbnvdwcppvvcjawcasndpkc0qc11n5x64fd1avzdi928ss";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this hash change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, backed this out.

@aneeshusa aneeshusa force-pushed the vagrant-remove-unused-Gemfile branch from e90a276 to 16a8e49 Compare October 5, 2018 16:24
@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/017xymp5i03qzigafnfx7sgf6602gmzq-bash-4.4-p23/bin/bash"
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/provisioners/salt/bootstrap-salt.sh: interpreter directive changed from "/bin/sh -" to "/nix/store/017xymp5i03qzigafnfx7sgf6602gmzq-bash-4.4-p23/bin/sh -"
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/hosts/darwin/scripts/install_virtualbox.sh: interpreter directive changed from "/bin/bash" to "/nix/store/017xymp5i03qzigafnfx7sgf6602gmzq-bash-4.4-p23/bin/bash"
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant.orig: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/7zjkzc17n2r3jhdqjrqss10bbgwk67bf-ruby-2.5.1/bin/ruby"
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/7zjkzc17n2r3jhdqjrqss10bbgwk67bf-ruby-2.5.1/bin/ruby"
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/.runner.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/017xymp5i03qzigafnfx7sgf6602gmzq-bash-4.4-p23/bin/bash"
checking for references to /build in /nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2...
running install tests
Vagrant smoke check passed
/nix/store/vlkqry0q5zy15mr4fjj2xzhf8axp3pv0-vagrant-2.1.2

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/mvzj2hwmzd67h8yxjmqgjjkn2zp1vz81-ruby-2.5.1/bin/ruby"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant.orig: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/mvzj2hwmzd67h8yxjmqgjjkn2zp1vz81-ruby-2.5.1/bin/ruby"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/hosts/darwin/scripts/install_virtualbox.sh: interpreter directive changed from "/bin/bash" to "/nix/store/f2lp21azk4w88f17zgf4mji64agb18ga-bash-4.4-p23/bin/bash"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/plugins/provisioners/salt/bootstrap-salt.sh: interpreter directive changed from "/bin/sh -" to "/nix/store/f2lp21azk4w88f17zgf4mji64agb18ga-bash-4.4-p23/bin/sh -"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/f2lp21azk4w88f17zgf4mji64agb18ga-bash-4.4-p23/bin/bash"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_docs.sh: interpreter directive changed from "/bin/bash" to "/nix/store/f2lp21azk4w88f17zgf4mji64agb18ga-bash-4.4-p23/bin/bash"
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_www.sh: interpreter directive changed from "/bin/bash" to "/nix/store/f2lp21azk4w88f17zgf4mji64agb18ga-bash-4.4-p23/bin/bash"
running install tests
Vagrant smoke check passed
/nix/store/f9mn7ia2fh1500j59br62z9i55qla7q9-vagrant-2.1.2

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: vagrant

Partial log (click to expand)

/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant.orig: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/wyqsn3wf4r7kf3z4s4fri831r2bgsxyp-ruby-2.5.1/bin/ruby"
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/bin/vagrant: interpreter directive changed from "/usr/bin/env ruby" to "/nix/store/wyqsn3wf4r7kf3z4s4fri831r2bgsxyp-ruby-2.5.1/bin/ruby"
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/.runner.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23/bin/bash"
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_docs.sh: interpreter directive changed from "/bin/bash" to "/nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23/bin/bash"
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/website_push_www.sh: interpreter directive changed from "/bin/bash" to "/nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23/bin/bash"
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2/lib/ruby/gems/2.5.0/gems/vagrant-2.1.2/scripts/sign.sh: interpreter directive changed from "/bin/bash" to "/nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23/bin/bash"
checking for references to /build in /nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2...
running install tests
Vagrant smoke check passed
/nix/store/hg14mj04p7rgv40fzxy4milkzbxhni24-vagrant-2.1.2

@Mic92 Mic92 merged commit 5694f1e into NixOS:master Oct 5, 2018
@angristan
Copy link
Member

Was is the process to update Vagrant? I'm a bit lost (#64302)

@aneeshusa aneeshusa deleted the vagrant-remove-unused-Gemfile branch January 7, 2022 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants