diff --git a/CHANGELOG.md b/CHANGELOG.md index b56448153c..26bd433dcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides/installing_cocoapods.html). +## Master +[CocoaPods](https://github.com/jverkoey/CocoaPods/compare/0.30.0...master) + +###### Enhancements + +* Unset the `CDPATH` env variable before shelling-out on `prepare_command` + [Marc Boquet](https://github.com/apalancat) + [#1943](https://github.com/CocoaPods/CocoaPods/pull/1943) + ## 0.30.0 [CocoaPods](https://github.com/jverkoey/CocoaPods/compare/0.29.0...0.30.0) diff --git a/lib/cocoapods/installer/pod_source_installer.rb b/lib/cocoapods/installer/pod_source_installer.rb index 074de7ef09..adee165e2d 100644 --- a/lib/cocoapods/installer/pod_source_installer.rb +++ b/lib/cocoapods/installer/pod_source_installer.rb @@ -114,12 +114,17 @@ def download_source # Runs the prepare command bash script of the spec. # + # @note Unsets the `CDPATH` env variable before running the + # shell script to avoid issues with relative paths + # (issue #1694). + # # @return [void] # def run_prepare_command return unless root_spec.prepare_command UI.section(" > Running prepare command", '', 1) do Dir.chdir(root) do + ENV.delete('CDPATH') prepare_command = root_spec.prepare_command.strip_heredoc.chomp full_command = "\nset -e\n" + prepare_command bash!(full_command) diff --git a/spec/unit/installer/pod_source_installer_spec.rb b/spec/unit/installer/pod_source_installer_spec.rb index 94c20496f4..33d7058d09 100644 --- a/spec/unit/installer/pod_source_installer_spec.rb +++ b/spec/unit/installer/pod_source_installer_spec.rb @@ -83,6 +83,13 @@ module Pod @installer.install! end.message.should.match /command not found/ end + + it "unsets $CDPATH environment variable" do + ENV['CDPATH'] = "BogusPath" + @spec.prepare_command = "cd Classes;ls Banana.h" + lambda { @installer.install! }.should.not.raise + end + end #--------------------------------------#