sttp
sttp copied to clipboard
native: Command failed with status URL_MALFORMAT / COULDNT_RESOLVE_HOST
I am testing scala-cli with sttp and always get one of these two errors reported
arm64 mac
//> using scala "3.2.1"
//> using lib "com.softwaremill.sttp.client3::core::3.8.5"
import sttp.client3.quick.*
@main def httptest() =
val url = uri"http://httpbin.org/ip"
val res = simpleHttpClient.send(quickRequest.get(url))
println(res.body)
> scala-cli test.scala --platform native
Compiling project (Scala 3.2.1, Scala Native)
Compiled project (Scala 3.2.1, Scala Native)
[info] Linking (1113 ms)
[info] Discovered 1557 classes and 11448 methods
[info] Optimizing (debug mode) (2126 ms)
[info] Generating intermediate code (1158 ms)
[info] Produced 10 files
[info] Compiling to native code (1980 ms)
[info] Total (6507 ms)
java.lang.RuntimeException: Command failed with status URL_MALFORMAT
at java.lang.StackTrace$.currentStackTrace(Unknown Source)
at java.lang.Throwable.fillInStackTrace(Unknown Source)
at sttp.client3.AbstractCurlBackend.lift(Unknown Source)
at sttp.client3.AbstractCurlBackend.handleBase(Unknown Source)
at sttp.client3.AbstractCurlBackend.send$$anonfun$1(Unknown Source)
at sttp.client3.AbstractCurlBackend$$Lambda$1.apply(Unknown Source)
at scala.scalanative.unsafe.Zone$.apply(Unknown Source)
at sttp.client3.AbstractCurlBackend.send(Unknown Source)
at sttp.client3.FollowRedirectsBackend.sendWithCounter(Unknown Source)
at sttp.client3.FollowRedirectsBackend.send(Unknown Source)
at sttp.client3.SimpleHttpClient.send(Unknown Source)
at test$package$.httptest(Unknown Source)
at httptest.main(Unknown Source)
at <none>.main(Unknown Source)
> scala-cli test.scala --platform native
java.lang.RuntimeException: Command failed with status COULDNT_RESOLVE_HOST
at java.lang.StackTrace$.currentStackTrace(Unknown Source)
at java.lang.Throwable.fillInStackTrace(Unknown Source)
at sttp.client3.AbstractCurlBackend.lift(Unknown Source)
at sttp.client3.AbstractCurlBackend.handleBase(Unknown Source)
at sttp.client3.AbstractCurlBackend.send$$anonfun$1(Unknown Source)
at sttp.client3.AbstractCurlBackend$$Lambda$1.apply(Unknown Source)
at scala.scalanative.unsafe.Zone$.apply(Unknown Source)
at sttp.client3.AbstractCurlBackend.send(Unknown Source)
at sttp.client3.FollowRedirectsBackend.sendWithCounter(Unknown Source)
at sttp.client3.FollowRedirectsBackend.send(Unknown Source)
at sttp.client3.SimpleHttpClient.send(Unknown Source)
at test$package$.httptest(Unknown Source)
at httptest.main(Unknown Source)
at <none>.main(Unknown Source)
This works correctly when running on the JVM
> scala-cli test.scala
Compiling project (Scala 3.2.1, JVM)
Compiled project (Scala 3.2.1, JVM)
{
"origin": "78.23.##.#"
}
This is a similar issue to the previously closed https://github.com/softwaremill/sttp/issues/376 https://gitter.im/scala-native/scala-native?at=5de7dc18c3d6795b9f2148c2
Hm this might be dependent on the curl version you have installed locally. I don't have an apple silicon mac to test, but sttp uses libcurl3 - can you maybe check what version you have locally?
And if you'd have any more details, please let us know - help around scala native integration would be appreciated :)
To be honest, I have no idea on how to check if I have libcurl3 and what version or how to make sure I have it
> curl --version
curl 7.85.0 (x86_64-apple-darwin22.0) libcurl/7.85.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0
Release-Date: 2022-08-31
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets
Hm version 7 ... either libcurl3-dev isn't libcurl version 3, but something else, or we are using an ancient variant
I found this
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libcurl.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libcurl.4.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libcurl.3.tbd
cat /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libcurl.3.tbd
--- !tapi-tbd
tbd-version: 4
targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
arm64e-macos, arm64e-maccatalyst ]
uuids:
- target: x86_64-macos
value: 23A6F8A0-1F12-34AE-9B68-911D1C7065AE
- target: x86_64-maccatalyst
value: 23A6F8A0-1F12-34AE-9B68-911D1C7065AE
- target: arm64-macos
value: 00000000-0000-0000-0000-000000000000
- target: arm64-maccatalyst
value: 00000000-0000-0000-0000-000000000000
- target: arm64e-macos
value: 6191B09E-D9C4-39A0-BC71-2F63D6F1BB40
- target: arm64e-maccatalyst
value: 6191B09E-D9C4-39A0-BC71-2F63D6F1BB40
install-name: '/usr/lib/libcurl.4.dylib'
current-version: 9
compatibility-version: 7
exports:
- targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
arm64e-macos, arm64e-maccatalyst ]
symbols: [ _curl_easy_cleanup, _curl_easy_duphandle, _curl_easy_escape,
_curl_easy_getinfo, _curl_easy_init, _curl_easy_option_by_id,
_curl_easy_option_by_name, _curl_easy_option_next, _curl_easy_pause,
_curl_easy_perform, _curl_easy_recv, _curl_easy_reset, _curl_easy_send,
_curl_easy_setopt, _curl_easy_strerror, _curl_easy_unescape,
_curl_easy_upkeep, _curl_escape, _curl_formadd, _curl_formfree,
_curl_formget, _curl_free, _curl_getdate, _curl_getenv, _curl_global_cleanup,
_curl_global_init, _curl_global_init_mem, _curl_global_sslset,
_curl_maprintf, _curl_mfprintf, _curl_mime_addpart, _curl_mime_data,
_curl_mime_data_cb, _curl_mime_encoder, _curl_mime_filedata,
_curl_mime_filename, _curl_mime_free, _curl_mime_headers,
_curl_mime_init, _curl_mime_name, _curl_mime_subparts, _curl_mime_type,
_curl_mprintf, _curl_msnprintf, _curl_msprintf, _curl_multi_add_handle,
_curl_multi_assign, _curl_multi_cleanup, _curl_multi_fdset,
_curl_multi_info_read, _curl_multi_init, _curl_multi_perform,
_curl_multi_poll, _curl_multi_remove_handle, _curl_multi_setopt,
_curl_multi_socket, _curl_multi_socket_action, _curl_multi_socket_all,
_curl_multi_strerror, _curl_multi_timeout, _curl_multi_wait,
_curl_multi_wakeup, _curl_mvaprintf, _curl_mvfprintf, _curl_mvprintf,
_curl_mvsnprintf, _curl_mvsprintf, _curl_pushheader_byname,
_curl_pushheader_bynum, _curl_share_cleanup, _curl_share_init,
_curl_share_setopt, _curl_share_strerror, _curl_slist_append,
_curl_slist_free_all, _curl_strequal, _curl_strnequal, _curl_unescape,
_curl_url, _curl_url_cleanup, _curl_url_dup, _curl_url_get,
_curl_url_set, _curl_version, _curl_version_info ]
...
It seems that both files libcurl.3.tbd and libcurl.4.tbd are the same and point to /usr/lib/libcurl.4.dylib (which does not exist but might be normal)