Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Wired errors during installation on Raspberry Pi with Ubuntu 16.04.2 #37

Closed
darthpelo opened this issue Apr 9, 2017 · 10 comments
Closed

Comments

@darthpelo
Copy link
Contributor

Hi @JohnSundell!
I want to report this error also if I know that Swift on ARM is not right now a stable environment. So if it's to hard to figure out the problem no worries, you can close this issue :)

The machine is a Raspberry Pi 2 with Ubuntu 16.04.2.
Swift version:

ubuntu@ Marathon (master)$ swift --version
Swift version 3.1 (swift-3.1-RELEASE)
Target: armv7-unknown-linux-gnueabihf

The errors are the same using the Make or the SPM:

Compile Swift Module 'Wrap' (1 sources)
Compile Swift Module 'Unbox' (1 sources)
Compile Swift Module 'Require' (1 sources)
Compile Swift Module 'Files' (1 sources)
Compile Swift Module 'ShellOut' (1 sources)
/home/ubuntu/Marathon/.build/checkouts/wrap.git-1764762263/Sources/Wrap.swift:264:26: error: use of unresolved identifier 'RegularExpression'
        let regex = try! RegularExpression(pattern: "(?<=[a-z])([A-Z])|([A-Z])(?=[a-z])", options: [])
                         ^~~~~~~~~~~~~~~~~
Foundation.NSRegularExpression:1:12: note: did you mean 'NSRegularExpression'?
open class NSRegularExpression : Foundation.NSObject, NSCopying, NSCoding {
           ^
/home/ubuntu/Marathon/.build/checkouts/require.git--488267411/Sources/Require.swift:31:29: error: use of unresolved identifier 'NSException'
            let exception = NSException(
                            ^~~~~~~~~~~
SwiftGlibc.exception:1:15: note: did you mean 'exception'?
public struct exception {
              ^
Foundation.NSExpression:1:12: note: did you mean 'NSExpression'?
open class NSExpression : Foundation.NSObject, NSSecureCoding, NSCopying {
           ^
Foundation.NSExceptionName:2:15: note: did you mean 'NSExceptionName'?
public struct NSExceptionName : RawRepresentable, Equatable, Hashable, Comparable {
              ^
<unknown>:0: error: build had 2 command failures
error: exit(1): /opt/swift/swift-3.1/usr/bin/swift-build-tool -f /home/ubuntu/Marathon/.build/release.yaml
Makefile:4: recipe for target 'install' failed
make: *** [install] Error 1

I have no idea why the compiler is "confused" with RegularExpression and NSExpression :(

Thanks in advance!

@JohnSundell
Copy link
Owner

JohnSundell commented Apr 10, 2017

Hi @darthpelo!

Thanks a lot for the report! I personally haven't had the chance to try installing Marathon on Linux yet, but it would be awesome to make it work on that platform as well as on macOS 👍

As far as I can tell there are two concrete tasks from looking at the build errors:

  • Make Require compile for Linux (it uses NSException, which is not part of the open source Swift version of Foundation).
  • Add a typealias for NSRegularExpression -> RegularExpression, so that it builds on Linux.

Since I'm not that much into Swift on Linux myself yet (it's still on my todo, since a year back 😅), I'd love help from the community on this one 😄

@darthpelo
Copy link
Contributor Author

Thanks for the reply @JohnSundell :)
If I have time today or tomorrow I will try to help.

@JohnSundell
Copy link
Owner

@darthpelo That would be really awesome 🎉 I think for ShellOut we can probably just surround the code using NSException with #if !platform(Linux).

@JohnSundell
Copy link
Owner

@darthpelo Sorry, my bad - it's not ShellOut that contains the NSException code - it's Require 😅

@darthpelo
Copy link
Contributor Author

@JohnSundell thanks! I was a little bit lost 😄

@darthpelo
Copy link
Contributor Author

@JohnSundell short update.

These are the first result after the build of my Marathon fork.

Ubuntu 16.04 (Vmware image)
screen shot 2017-04-11 at 10 54 46

Ubuntu 16.04 (Raspberry Pi)
screen shot 2017-04-11 at 10 54 21

My Mac
screen shot 2017-04-11 at 10 58 48

Regarding the DistapatchQueue issue, the solution it's easy: import Dispatch in Script.swift

#if os(Linux)
    import Dispatch
#endif

Right now I builded in develop and not release because swift build -c release -Xswiftc -static-stdlib, if I understood, needs Xcode, right?

@JohnSundell
Copy link
Owner

@darthpelo That is really awesome 👏 Yeah, we can build release on Linux, but not statically link the standard library (AFAIK). So just swift build -c release on Linux. Feel free to open PRs with your changes once you're ready and we'll get them merged ASAP. Super excited about getting Marathon up and running on Linux. Did you try running the tests btw?

@darthpelo
Copy link
Contributor Author

darthpelo commented Apr 11, 2017

@JohnSundell yes swift build -c release it's enough. Right now only install doesn't work and return a generic 💥 Failed to compile script.

About tests:
now I am testing Marathon, Require and Wrap on my Mac to be sure that I did not broke anything 😅. Then I need to understand how tests work with Linux.

@darthpelo
Copy link
Contributor Author

darthpelo commented Apr 11, 2017

@JohnSundell Marathon and Wrap tests are all ✅ on Mac.
On Linux platform only Wrap has all tests ✅.

I have 4 ❌ https://github.com/darthpelo/Marathon/pull/1 but I'm not sure about the causes.
These are the errors:

testAddingAndRemovingRemotePackage

Test Case 'MarathonTests.AddingAndRemovingRemotePackage' started at 12:37:40.118
<EXPR>:0: error: MarathonTests.AddingAndRemovingRemotePackage : threw error "💥  Cannot remove package 'files' - no such package has been added
👉  Did you mean to remove the cache data for a script? If so, add '.swift' to its path
   To list all added packages run 'marathon list'"
Test Case 'MarathonTests.AddingAndRemovingRemotePackage' failed (9.49 seconds)

testInstallingLocalScript

Test Case 'MarathonTests.testInstallingLocalScript' started at 12:40:04.579
<EXPR>:0: error: MarathonTests.testInstallingLocalScript : threw error "💥  Failed to compile script"
Test Case 'MarathonTests.testInstallingLocalScript' failed (18.473 seconds)

testInstallingRemoteScriptWithDependencies

Test Case 'MarathonTests.testInstallingRemoteScriptWithDependencies' started at 12:40:23.052
<EXPR>:0: error: MarathonTests.testInstallingRemoteScriptWithDependencies : threw error "💥  Failed to compile script"
Test Case 'MarathonTests.testInstallingRemoteScriptWithDependencies' failed (17.406 seconds)

testUsingMarathonfileToInstallDependencies

Test Case 'MarathonTests.testUsingMarathonfileToInstallDependencies' started at 12:40:49.292
<EXPR>:0: error: MarathonTests.testUsingMarathonfileToInstallDependencies : threw error "💥  Failed to compile script"
Test Case 'MarathonTests.testUsingMarathonfileToInstallDependencies' failed (26.146 seconds)

If I'm right are not related to Require and Wrap, so for now I would like to create the PRs for these two.

What do you think about it?

@darthpelo
Copy link
Contributor Author

@JohnSundell I close this issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants