Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6548] SwiftPM's POSIX.chdir never works when binary is found via $PATH #4904

Open
swift-ci opened this issue Dec 6, 2017 · 2 comments
Open
Labels
bug good first issue Good for newcomers Edit

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Dec 6, 2017

Previous ID SR-6548
Radar None
Original Reporter jaybuff (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, StarterBug
Assignee legendecas (JIRA)
Priority Medium

md5: 7f6b9fff863f8eada827047e65debf1f

Issue Description:

I'm using SwiftPM's Utility product and ran into an issue with chdir. To reproduce the program has to be found on the path:

swift package init --type executable

  1. add swiftpm dependency to Package.swift like this:
    .package(url: "https://github.com/apple/swift-package-manager.git", .exact("0.1.0"))

$ cat Sources/ChdirProg/main.swift
import POSIX
try chdir("/tmp")

swift build
export PATH=$PWD/.build/debug/:$PATH
ChdirProg
fatal error: Error raised at top level: realpath error: No such file or directory (2): ChdirProg: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65.2/src/swift/stdlib/public/core/ErrorType.swift, line 187

This is because POSIX/chdir.swift calls realpath(CommandLine.arguments.first when the program name is resolved via $PATH.

I suspect this causes issues with --package-path, but am unsure how to cause this bug to manifest itself with swift build. Perhaps when swift build re-execs swift-build it always uses the full path?

@swift-ci
Copy link
Contributor Author

Comment by Lucas Woo (JIRA)

Hi, I've sent a PR trying to fix this issue

@hartbit
Copy link
Collaborator

hartbit commented Jun 8, 2018

legendecas (JIRA User) Hey! I've assigned the issue to you to make sure nobody thinks its "free" 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
@tomerd tomerd added good first issue Good for newcomers Edit and removed Package Manager labels May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers Edit
Projects
None yet
Development

No branches or pull requests

3 participants