You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: swiftProgramming language (swift.org)
Yeah I'm running into this too. Without looking into it too deeply, it seems like pkgs.swift is a lot more barebones on 23.05 than 22.11 and doesn't include a lot of the things that would normally be distributed in the toolchain (like the package manager in this case)?
For example, if you add nixpkgs/23.05#swiftPackages.swiftpm to your environment, package subcommand will run, but calling swift build will result in an error (error: toolchain is invalid: could not find ar).
Conversely, reverting to the swift found in 22.11 seems to restore all the missing functionality without the need of any additional packages.
Can @stephank or any of the other maintainers (@dtzWill@trepetti@dduan@Trundle) give information on what has changed with how swift is packaged in 22.11 vs. 23.05? Also, can you give simple instructions on what packages are required to get the complete toolchain as is typically bundled with swift (i.e. the commands that are visible when simply calling swift)?
Thanks,
smkuehnhold
Reacted by godalming123, Suraj, Spotlight, Jhonatan A. and Dimitar Nestorov
airstation:~ ic$ nix-shell -p swift
[nix-shell:~]$ swift build
/nix/store/sccf314q4yfs2n7669qjqicg9hcmxr55-swift-wrapper-5.8/bin/swift: line 33: exec: swift-build: not found
is fixable by adding swiftPackages.swiftpm:
airstation:~ ic$ nix-shell -p swift swiftPackages.swiftpm
[nix-shell:~]$ swift build
error: Could not find Package.swift in this directory or any of its parent directories.
airstation:~ ic$ nix-shell -p swift
[nix-shell:~]$ swift build
/nix/store/sccf314q4yfs2n7669qjqicg9hcmxr55-swift-wrapper-5.8/bin/swift: line 33: exec: swift-build: not found
is fixable by adding swiftPackages.swiftpm:
airstation:~ ic$ nix-shell -p swift swiftPackages.swiftpm
[nix-shell:~]$ swift build
error: Could not find Package.swift in this directory or any of its parent directories.
I haven't tested this since I just used another package manager, but I will assume that this works and close the issue.
Probably something some of you have already done, but I've created a small flake to setup a docker-based development environment as a workaround until this is fixed.
FYI, I posted my solution to the neighbouring thread, which I used to build another swift app which requires packaging.
I verified it works both for nix-shell and flakes' nix develop on the latest nixpkgs-unstable (to the date).
However, I haven't managed to make it work with nix shell because the workaround used requires overriding stdenv (and I'm not sure it's easy enough with nix shell though I didn't bother TBH, as nix develop is just fine for my needs)
UPD: nix shell evaluates flake' package attribute and is a tool for temporary accessing a package, hence not applicable here.
Effective difference between nix-shell and nix develop is that the former permits impurity OOB. To match this behaviour, pure-by-design nix develop should be called with --impure flag
Swift has been updated to Swift 6.x. Please reopen if this continues to be an issue. Swift should be able to find SwiftPM as long as it is on your path.
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: swiftProgramming language (swift.org)
Activity
smkuehnhold commentedon Aug 11, 2023
Yeah I'm running into this too. Without looking into it too deeply, it seems like
pkgs.swiftis a lot more barebones on 23.05 than 22.11 and doesn't include a lot of the things that would normally be distributed in the toolchain (like the package manager in this case)?For example, if you add
nixpkgs/23.05#swiftPackages.swiftpmto your environment,packagesubcommand will run, but callingswift buildwill result in an error (error: toolchain is invalid: could not find ar).Conversely, reverting to the swift found in 22.11 seems to restore all the missing functionality without the need of any additional packages.
Can @stephank or any of the other maintainers (@dtzWill @trepetti @dduan @Trundle) give information on what has changed with how swift is packaged in 22.11 vs. 23.05? Also, can you give simple instructions on what packages are required to get the complete toolchain as is typically bundled with swift (i.e. the commands that are visible when simply calling
swift)?Thanks,
smkuehnhold
ink-splatters commentedon Nov 21, 2023
For the specified nixpkgs:
this broken shell:
is fixable by adding
swiftPackages.swiftpm:godalming123 commentedon Nov 22, 2023
I haven't tested this since I just used another package manager, but I will assume that this works and close the issue.
smkuehnhold commentedon Nov 22, 2023
@godalming123 Can you please re-open the issue since this is problem is not unique to you?
What @ink-splatters did is no different than what I tried. If you try to build even the most basic package, you will get the
arerror.Running
Results in:
smkuehnhold commentedon Nov 22, 2023
Thanks @godalming123
smkuehnhold commentedon Dec 2, 2023
Probably something some of you have already done, but I've created a small flake to setup a docker-based development environment as a workaround until this is fixed.
ink-splatters commentedon Dec 4, 2023
FYI, I posted my solution to the neighbouring thread, which I used to build another swift app which requires packaging.
I verified it works both for
nix-shelland flakes'nix developon the latest nixpkgs-unstable (to the date).However, I haven't managed to make it work with
nix shellbecause the workaround used requires overriding stdenv (and I'm not sure it's easy enough withnix shellthough I didn't bother TBH, asnix developis just fine for my needs)UPD:
nix shellevaluates flake'packageattribute and is a tool for temporary accessing a package, hence not applicable here.Effective difference between
nix-shellandnix developis that the former permits impurity OOB. To match this behaviour, pure-by-designnix developshould be called with--impureflagreckenrode commentedon Oct 13, 2026
Swift has been updated to Swift 6.x. Please reopen if this continues to be an issue. Swift should be able to find SwiftPM as long as it is on your path.