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-2744] Errors when running REPL on Ubuntu 16.04 #3931

Open
Bouke opened this issue Sep 23, 2016 · 10 comments
Open

[SR-2744] Errors when running REPL on Ubuntu 16.04 #3931

Bouke opened this issue Sep 23, 2016 · 10 comments

Comments

@Bouke
Copy link
Contributor

Bouke commented Sep 23, 2016

Previous ID SR-2744
Radar None
Original Reporter @Bouke
Type Bug
Environment

Ubuntu server 16.04, Swift 3.0.1 Preview 1

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Linux
Assignee None
Priority Medium

md5: 9d11eb334a20f053d1c5a5b0c149517c

relates to:

  • SR-2743 Incomplete install instructions for Ubuntu

Issue Description:

I installed Ubuntu server 16.04 with OpenSSH + default options. When running the following code, there's an error about missing symbols.

$ swift
Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for assistance.
  1> import Foundation
  2> NSURL(string: "http://swift.org")
error: Couldn't lookup symbols:
  type metadata accessor for Foundation.NSURL
  Foundation.NSURL.__allocating_init (string : Swift.String) -> Swift.Optional<Foundation.NSURL>
@belkadan
Copy link

cc @shahmishal and @trfiala, who've been bringing Ubuntu 16 testing online.

@trfiala
Copy link
Mannequin

trfiala mannequin commented Sep 23, 2016

I'll have a look. Thanks!

@trfiala
Copy link
Mannequin

trfiala mannequin commented Dec 28, 2016

Pulling myself off of this - no longer with Apple.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 5, 2017

Comment by Mason Mark (JIRA)

I didn't encounter this issue with Swift 3, but now I do see it with Swift 4.

Today I tried installing Swift 4.0.2 on a freshly-provisioned Ubuntu Server 16.04 (64-bit) machine.

I found that the REPL was broken on Linux in the same well-known way as it is with Swift 3 ("error: could not build C module 'CoreFoundation'"), but after applying the workaround for that issue from SR-2783 (fix permissions of Swift header files after installing), I next encountered the error described in this issue:

root@ubuntu:~# /swift/usr/bin/swift
Welcome to Swift version 4.0.2 (swift-4.0.2-RELEASE). Type :help for assistance.
  1> import Foundation
  2>
  3>
  4>
  5> let foo = FileManager.default
foo: Foundation.FileManager = <extracting data from value failed>

error: Couldn't lookup symbols:
  type metadata accessor for Foundation.FileManager

  5> let bar = NSString()
bar: Foundation.NSString = <extracting data from value failed>

error: Couldn't lookup symbols:
  Foundation.NSString.__allocating_init() -> Foundation.NSString
  type metadata accessor for Foundation.NSString

  5> ^C
  5> ^D
root@ubuntu:~#

The fact that this issue's original report was for Swift 3, where I didn't see this issue, and now I see it with Swift 4 on a new, fairly minimal, Ubuntu box, but most people don't (e.g. this thread has somebody reporting this problem, quickly followed by somebody else replying "Hmm doesn't happen to me") makes me think this must be some kind of missing dependency or other environmental issue.

But, I haven't found a workaround at this stage, so Swift 4.0.2 isn't working on Ubuntu 16.04 for me (well at least, the REPL isn't).

@swift-ci
Copy link
Contributor

swift-ci commented Nov 5, 2017

Comment by Mason Mark (JIRA)

Just as an additional data point: I played around with default installations of various Ubuntu flavors to see where this did and did not happen. One thing I did find is that this error does occur on Ubuntu 17.10 Server, and does not occur on Ubuntu 17.10 Desktop.

I know the 17.10 releases aren't "supported" but I thought this still might be helpful, as it seems likely that the difference arises from the Server release missing some package that is pre-installed on the Desktop release.

Unfortunately I don't know what package that is; I did apt list --installed on each machine and compared the output; seems that the Desktop release includes 1,126 more packages than the Server release.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 7, 2017

Comment by Mason Mark (JIRA)

OK, I found out libcurl3 is the dependency that was missing, and causing the REPL to fail with error: Couldn't lookup symbols: when trying to import Foundation (and other libraries).

This transcript, from a freshly-installed Ubuntu 17.10 server machine, shows the Swift 4.0.2 REPL failing in this manner, and then being fixed by apt-get install libcurl3:

In this example, everything is being done as the root user. The Swift 4.0.2 tarball has been extracted to /swift. The clang headers location is supplied on the command line when invoking swift to work around bug SR-5524.

root@ubuntu:~#
root@ubuntu:~# /swift/usr/bin/swift -I /swift/usr/lib/swift/clang/include/
Welcome to Swift version 4.0.2 (swift-4.0.2-RELEASE). Type :help for assistance.
  1>
  2> import Foundation
  3>
  4> let foo = NSString()
foo: Foundation.NSString = <extracting data from value failed>

error: Couldn't lookup symbols:
  Foundation.NSString.__allocating_init() -> Foundation.NSString
  type metadata accessor for Foundation.NSString

  4> ^C
  4> ^D
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# sudo apt-get install libcurl3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpsl5 librtmp1 publicsuffix
The following NEW packages will be installed:
  libcurl3 libpsl5 librtmp1 publicsuffix
0 upgraded, 4 newly installed, 0 to remove and 11 not upgraded.
Need to get 386 kB of archives.
After this operation, 1,082 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu artful/main amd64 libpsl5 amd64 0.18.0-2 [40.6 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu artful/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-1 [54.2 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libcurl3 amd64 7.55.1-1ubuntu2.1 [196 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu artful/main amd64 publicsuffix all 20170809.0951-1 [95.9 kB]
Fetched 386 kB in 1s (301 kB/s)
Selecting previously unselected package libpsl5:amd64.
(Reading database ... 79121 files and directories currently installed.)
Preparing to unpack .../libpsl5_0.18.0-2_amd64.deb ...
Unpacking libpsl5:amd64 (0.18.0-2) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../librtmp1_2.4+20151223.gitfa8646d.1-1_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Selecting previously unselected package libcurl3:amd64.
Preparing to unpack .../libcurl3_7.55.1-1ubuntu2.1_amd64.deb ...
Unpacking libcurl3:amd64 (7.55.1-1ubuntu2.1) ...
Selecting previously unselected package publicsuffix.
Preparing to unpack .../publicsuffix_20170809.0951-1_all.deb ...
Unpacking publicsuffix (20170809.0951-1) ...
Setting up libpsl5:amd64 (0.18.0-2) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Setting up publicsuffix (20170809.0951-1) ...
Setting up libcurl3:amd64 (7.55.1-1ubuntu2.1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# /swift/usr/bin/swift -I /swift/usr/lib/swift/clang/include/
Welcome to Swift version 4.0.2 (swift-4.0.2-RELEASE). Type :help for assistance.
  1>
  2> import Foundation
  3>
  4> let foo = NSString()
foo: Foundation.NSString = {
  Foundation.NSObject = {}
  _cfinfo = {
    info = 1920
    pad = 0
  }
  _storage = ""
}
  5> ^C
  5> ^D
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# uname -a
Linux ubuntu 4.13.0-16-generic #&#8203;19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu:~#

@swift-ci
Copy link
Contributor

swift-ci commented Nov 7, 2017

Comment by Mason Mark (JIRA)

This issue SR-2744 caused by missing libcurl3 dependency; overlaps with the discussion on 2743

@swift-ci
Copy link
Contributor

swift-ci commented Nov 7, 2017

Comment by Mason Mark (JIRA)

Now that I know it's missing libcurl3, a quick search for "swift libcurl3" leads to... the very previous issue to this, SR-2743. That issue's title is probably more relevant than this one's; this issue could be closed as a duplicate of that one, if libcurl3 was added to the SR-2743's description.

@Bouke
Copy link
Contributor Author

Bouke commented Nov 7, 2017

On Ubuntu 16.04, after applying the header permission fix and installing libcurl3, I still can't import Foundation. This bug report is not a duplicate of SR-2743.

bouke@ubuntu:~$ swift -version
Swift version 4.0 (swift-4.0-RELEASE)
Target: x86_64-unknown-linux-gnu
bouke@ubuntu:~$ swift
Welcome to Swift version 4.0 (swift-4.0-RELEASE). Type :help for assistance.
1> import Foundation
/home/bouke/.swiftenv/versions/4.0/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: note: while building module 'SwiftGlibc' imported from /home/bouke/.swiftenv/versions/4.0/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:
#include <sys/types.h>
^

<module-includes>:3:10: note: in file included from <module-includes>:3:
#include "///usr/include/utmp.h"
^

///usr/include/utmp.h:23:10: note: in file included from ///usr/include/utmp.h:23:
#include <sys/types.h>
^

error: /usr/include/x86_64-linux-gnu/sys/types.h:146:10: error: 'stddef.h' file not found
#include <stddef.h>
^

<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "CoreFoundation.h"
^

error: /home/bouke/.swiftenv/versions/4.0/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: error: could not build module 'SwiftGlibc'
#include <sys/types.h>
^

/home/bouke/.swiftenv/versions/4.0/usr/lib/swift/CoreFoundation/CFStream.h:20:10: note: while building module 'CDispatch' imported from /home/bouke/.swiftenv/versions/4.0/usr/lib/swift/CoreFoundation/CFStream.h:20:
#include <dispatch/dispatch.h>
^

<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "dispatch.h"
^

/home/bouke/.swiftenv/versions/4.0/usr/lib/swift/dispatch/dispatch.h:30:10: note: in file included from /home/bouke/.swiftenv/versions/4.0/usr/lib/swift/dispatch/dispatch.h:30:
#include <os/linux_base.h>
^

/home/bouke/.swiftenv/versions/4.0/usr/lib/swift/os/linux_base.h:17:10: note: in file included from /home/bouke/.swiftenv/versions/4.0/usr/lib/swift/os/linux_base.h:17:
#include <sys/sysmacros.h>
^

error: /usr/include/x86_64-linux-gnu/sys/sysmacros.h:22:10: error: could not build module 'SwiftGlibc'
#include <features.h>
^

error: could not build C module 'CoreFoundation'

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2017

Comment by Mason Mark (JIRA)

@Bouke I see. It looks like you may also need to apply the "clang header location fix" — have you tried that?

E.g. pass the path to the clang headers as a command-line argument to swift, something like:

swift -I /swift/usr/lib/swift/clang/include/

Or, alternatively, by setting these environment variables (taken from this comment by MatiMax (JIRA User)):

export C_INCLUDE_PATH=/swift/usr/lib/swift/clang/include/
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH

(paths will vary depending where you unpacked the swift tarball)

I have not yet had a chance to try with Ubuntu Server 16.04, but I find that to get Swift to work on Ubuntu Server I have to do all of these:

1. Do apt-get install libcurl3 libpython2.7 clang

2. Fix the header permissions (example here)

3. Fix the missing clang headers issue using one of the methods above.

Only if I do all three of those things does Swift seem to work on Ubuntu Server or other minimal Ubuntu install.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants