Skip to content


Unset the `CDPATH` env variable before shelling-out. #1694 #1943

merged 3 commits into from

4 participants


I guess bash is only used in run_prepare_command, but I'm not sure if the CDPATH should be unset globally at some other point so it can't create problems in the future.
Also, should this have a test?


@apalancat it would be great for this to have a test, yes!


Also a small note in the documentation of the method referencing the original issue would be helpful... finally don't forget to add an entry to changelog and credit yourself!


Not sure if I messed up by doing a merge of 0.30 and updating the PR, let me know if I should change anything.
Otherwise I think it should be OK, tests & doc


Issue has been confirmed by @AhmadAlokush

@fabiopelosin fabiopelosin merged commit 9a4e304 into CocoaPods:master

1 check passed

Details default The Travis CI build passed

Thanks :wine_glass:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
@@ -2,6 +2,15 @@
To install or update CocoaPods see this [guide](
+## Master
+###### Enhancements
+* Unset the `CDPATH` env variable before shelling-out on `prepare_command`
+ [Marc Boquet](
+ [#1943](
## 0.30.0
5 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
7 spec/unit/installer/pod_source_installer_spec.rb
@@ -83,6 +83,13 @@ module Pod
end.message.should.match /command not found/
+ it "unsets $CDPATH environment variable" do
+ ENV['CDPATH'] = "BogusPath"
+ @spec.prepare_command = "cd Classes;ls Banana.h"
+ lambda { @installer.install! }.should.not.raise
+ end
Something went wrong with that request. Please try again.