JohnSundell / Marathon

[DEPRECATED] Marathon makes it easy to write, run and manage your Swift scripts 🏃

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mismatch between Swift version and tools version

seanlabastille opened this issue · comments

In Xcode 9.1 (9B55) it appears there is a mismatch between the Swift version (4.0.2) and the Swift package manager version (4.0.0)
17-11-01 14:01:48 ➜0  ~  xcodebuild -version 
Xcode 9.1
Build version 9B55
17-11-01 14:01:56 ➜  ~  xcrun swift --version      
Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38)
Target: x86_64-apple-macosx10.9
17-11-01 14:02:05 ➜  ~  xcrun swift build --version  
Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13502)
17-11-01 14:02:11 ➜  ~  xcrun swift package --version
Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13502)

This causes issues when using Marathon as the header for the generated Package.swift file is incorrect.

return "// swift-tools-version:\(versionString)"

marathon run Script.swift --verbose                                                 
🏃  $ cd "/Users/sean/.marathon/Scripts/Cache/-Users-sean-Documents-Script/" && readlink OriginalFile
   /Users/sean/Documents/Script.swift
   $ cd "/Users/sean/Documents/" && /usr/bin/env xcrun --sdk macosx swift --version
   Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38)
   Target: x86_64-apple-macosx10.9
   $ cd "/Users/sean/.marathon/Scripts/Cache/-Users-sean-Documents-Script/" && /usr/bin/env xcrun --sdk macosx swift build -C /Users/sean/.marathon/Scripts/Cache/-Users-sean-Documents-Script/ --enable-prefetching 
   warning: '--chdir/-C' option is deprecated; use '--package-path' instead
   error: package at '/Users/sean/.marathon/Scripts/Cache/-Users-sean-Documents-Script/' requires a minimum Swift tools version of 4.0.2 (currently 4.0.0)
💥  Failed to compile script

It seems to me that the version checks for the Swift compiler and SPM might need to be separated.

I've submitted a pull request (#138) against this issue. It's got some junk mixed in which I'm sorry for, but I had to get a version working quickly. You're welcome to do with this as you please.

Thanks, though, for pointing out where the problem was. It accelerated the "fix" quite a bit.

(I'd personally like to maybe see a regex against the version string, because right now it feels very brittle)

Fixed! Will submit a new version to Homebrew ASAP, in the meantime you can install the latest master go get around this problem 👍 Thanks for reporting it @flufff42 🙏

Still happened on macOS High Sierra 10.13.1 with master branch, same output as @flufff42 's, my Xcode version is 9.1, swift version is Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38), swift package manager version is Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13502)

I'm also facing the same issue on macOS High Sierra with marathon-swift version 1.0.1.

Still have the same issue on macos 10.13.3
Installed marathon with swift package manager

1.0.1 is the latest version of Marathon on homebrew, which has this issue. It's also the first listed installation option.

Still have same issue.

I had the same issue, fixed it by uninstalling the brew package and installing the latest '2.0.2' directly from the repo.

Had the same issue, even after reinstalling Marathon 2.0.2 with mint. Deleting the ~/.marathon folder resolved the issue for me

I'm having the same issue here... Deleting ~/.marathon didn't solve the problem.