diff options
author | Bundlerbot <bot@bundler.io> | 2019-11-06 16:03:03 +0000 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-11-07 16:41:44 +0100 |
commit | ba2efdacdab5bfa2d3a4ab6c640d01eed6387fef (patch) | |
tree | 8c89a4176fa7362ee0b440742c78cb527fb71980 | |
parent | eaf05e5b21a6fe09a123aaaf868f251c66e1a05f (diff) | |
download | bundler-ba2efdacdab5bfa2d3a4ab6c640d01eed6387fef.tar.gz |
Merge #7425
7425: Properly avoid readline crashes when running specs on Windows r=deivid-rodriguez a=deivid-rodriguez
### What was the end-user problem that led to this PR?
The problem was that specs cannot be run on windows unless you add the ugly workaround currently included in the azure pipelines config.
### What was your diagnosis of the problem?
My diagnosis was that the `tmp/tmpdir` and `tmp/home` folder (which act as `ENV["HOME"]` and `ENV["TMPDIR"]` for our specs) are emptied in an `around(:each)` hook, but there's some stuff going before that and after `ENV["HOME"]` and `ENV["TMPDIR"]` are set (on a `before(:suite)` hook) that might require the folders they point to to exist.
This is the case of rb-readline, used on Windows:
https://github.com/ConnorAtherton/rb-readline/blob/9fba246073f78831b7c7129c76cc07d8476a8892/lib/rbreadline.rb#L1096
or any bundler's code that uses `Bundler.user_home`:
https://github.com/bundler/bundler/blob/f83412ae8cda9c933b8cf33ec2abfb78a408daab/lib/bundler.rb#L227
For example, running `rm -rf tmp/ && bin/rspec ./spec/other/major_deprecation_spec.rb:368` prints a warning about this that it's fixed by this PR:
```
$ rm -rf tmp/ && bin/rspec ./spec/other/major_deprecation_spec.rb:368
Randomized with seed 1955
(... stuff ...)
`/home/deivid/Code/bundler/tmp/1/home` is not a directory.
Bundler will use `/tmp/bundler/home/deivid' as your home directory temporarily.
.
Retried examples: 0
Finished in 5.26 seconds (files took 0.17927 seconds to load)
1 example, 0 failures
Randomized with seed 1955
```
### What is your fix for the problem, implemented in this PR?
My fix is to create the folders as soon as the environment variables are set.
### Why did you choose this fix out of the possible options?
I chose this fix because it's more general that a workaround living on a specific CI config.
Fixes #6902.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
(cherry picked from commit 3eabc1ca06e39e455469adf72e5d57e292dd08fc)
-rw-r--r-- | .azure-pipelines/steps.yml | 6 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 3 |
2 files changed, 3 insertions, 6 deletions
diff --git a/.azure-pipelines/steps.yml b/.azure-pipelines/steps.yml index 3c8f2f9512..50e13fb499 100644 --- a/.azure-pipelines/steps.yml +++ b/.azure-pipelines/steps.yml @@ -10,12 +10,6 @@ steps: displayName: 'ruby -v + ridk version' - script: | - mkdir tmp - cd tmp - mkdir home - displayName: 'work around readline crash (for https://github.com/bundler/bundler/issues/6902)' - -- script: | bash .azure-pipelines\patch_readline.sh displayName: 'patch local readline implementation (for https://github.com/bundler/bundler/issues/6907)' diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index da95837b1b..1093362d81 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -67,6 +67,9 @@ module Spec manifest_path.open("w") {|f| f << manifest.join } end + FileUtils.mkdir_p(Path.home) + FileUtils.mkdir_p(Path.tmpdir) + ENV["HOME"] = Path.home.to_s ENV["TMPDIR"] = Path.tmpdir.to_s |