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
- Verify the path exists and is a folder: `ls -ld <path>`
- Use an absolute path to avoid cwd-relative surprises
- 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
- Always pass an absolute directory to --project-directory
- Remember the value is a folder, not the .xcodeproj file
- Validate paths from scripts with File.directory? before invoking pod
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
- No `Podfile' found in the project directory.
- No `Podfile.lock' found in the project directory, run `pod i
- Repo name `trunk` is reserved for CocoaPods' main spec repo
- To setup the master specs repo, please run `pod setup`.
- Unable to find the `#{@repo}` repo. If it has not yet been c
AI-assisted analysis of CocoaPods/CocoaPods@b80e113e28 (2026-08-21).
Data as JSON: /api/errors/41ddd7dc4cdcd9a8.
Report an issue: GitHub.