CocoaPods/CocoaPods · error · Informative

`#{@project_directory}` is not a valid directory.

Error message

`#{@project_directory}` is not a valid directory.

What it means

The --project-directory option expands the given path, assigns config.installation_root, and in validate! raises Informative unless Pathname#directory? is true. Both a nonexistent path and a path that is a regular file fail the check, so the value must name an existing folder.

Source

Thrown at lib/cocoapods/command/options/project_directory.rb:30

          end
        end

        def self.included(base)
          base.extend(Options)
        end

        def initialize(argv)
          if project_directory = argv.option('project-directory')
            @project_directory = Pathname.new(project_directory).expand_path
          end
          config.installation_root = @project_directory
          super
        end

        def validate!
          super
          if @project_directory && !@project_directory.directory?
            raise Informative, "`#{@project_directory}` is not a valid directory."
          end
        end
      end
    end
  end
end

View on GitHub (pinned to b80e113e28)

Solutions

  1. Verify the path exists and is a folder: `ls -ld <path>`
  2. Use an absolute path to avoid cwd-relative surprises
  3. Create the directory first if it is expected but missing

Example fix

# before
$ pod install --project-directory=MyApp.xcodeproj
[!] `/abs/MyApp.xcodeproj` is not a valid directory.

# after
$ pod install --project-directory=MyApp   # the folder containing the project
Defensive patterns

Strategy: validation

Validate before calling

dir = File.expand_path(ENV['POD_PROJECT_DIR'] || '.')
abort "#{dir} is not a directory" unless File.directory?(dir)
system('pod', 'install', '--project-directory', dir) or exit $?.exitstatus

Prevention

When it happens

Trigger: `pod install --project-directory=X` where X does not exist, X is a file (e.g. the .xcodeproj bundle), or a mistyped relative path resolved against the wrong cwd.

Common situations: Passing the Xcode project file instead of its containing folder; relative paths interpreted from a different working directory in scripts; stale paths after the project moved.

Related errors


AI-assisted analysis of CocoaPods/CocoaPods@b80e113e28 (2026-08-21). Data as JSON: /api/errors/41ddd7dc4cdcd9a8. Report an issue: GitHub.