typelead / gradle-eta

Gradle plugin for the Eta programming language
BSD 3-Clause "New" or "Revised" License
30 stars 7 forks source link

Unable to access jarfile #22

Closed lippling closed 6 years ago

lippling commented 6 years ago

I added servant as a dependency to eta-init and got this error:

Building aeson-1.2.3.0 (lib)...

  Failed to build aeson-1.2.3.0.
  Build log (
  /Users/alexander/.etlas/logs/eta-0.8.0.2/aeson-1.2.3.0-793fca63627375df1ce6583a6490b7feec9137adff0912d7686f82b8ac98f1f2.log
  ):
  Configuring library for aeson-1.2.3.0..
  Preprocessing library for aeson-1.2.3.0..
  Building library for aeson-1.2.3.0..

  [ 1 of 23] Compiling Data.Attoparsec.Time.Internal
  [ 2 of 23] Compiling Data.Attoparsec.Time
  [ 3 of 23] Compiling Data.Aeson.Types.Internal
  [ 4 of 23] Compiling Data.Aeson.Types.Generic
  [ 5 of 23] Compiling Data.Aeson.Parser.UnescapePure
  [ 6 of 23] Compiling Data.Aeson.Parser.Unescape
  [ 7 of 23] Compiling Data.Aeson.Parser.Time
  [ 8 of 23] Compiling Data.Aeson.Parser.Internal
  [ 9 of 23] Compiling Data.Aeson.Parser
  [10 of 23] Compiling Data.Aeson.Internal.Time
  [11 of 23] Compiling Data.Aeson.Internal.Functions
  [12 of 23] Compiling Data.Aeson.Encoding.Builder
  [13 of 23] Compiling Data.Aeson.Encoding.Internal
  [14 of 23] Compiling Data.Aeson.Encoding
  [15 of 23] Compiling Data.Aeson.Types.ToJSONeta: While in operation Call:
  Exception: {handle: fd:15}: Eta.REPL.Message.remoteCall: end of file
  eta-serv terminated (1)
  Error: Unable to access jarfile 

  Process Standard Error:
  etlas: Failed to build aeson-1.2.3.0 (which is required by servant-0.13.0.1).
  See the build log above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 27s
3 actionable tasks: 2 executed, 1 up-to-date

The Gradle file looks like this:

plugins {
    id 'com.typelead.eta' version '0.7.2'
    id 'application'
}

eta {
    version = '0.8.0b2'
    etlasVersion = '1.4.0.0'
}

dependencies {
  compile eta('base:4.8.2.0')
  compile eta('servant:0.13.0.1')
}
Jyothsnasrinivas commented 6 years ago

@lippling Thanks for reporting this. Can you share the output of the following command?

ls -al ~/.etlas/binaries/cdnverify.eta-lang.org/eta-0.8.0.2/binaries/x86_64-osx/
lippling commented 6 years ago
ls -al ~/.etlas/binaries/cdnverify.eta-lang.org/eta-0.8.0.2/binaries/x86_64-osx/
total 165704
drwxr-xr-x  6 alexander  staff       192 Jun 13 15:57 .
drwxr-xr-x  3 alexander  staff        96 Jun 13 15:57 ..
-rwxr-xr-x  1 alexander  staff  70705900 Jun 13 15:57 eta
-rwxr-xr-x  1 alexander  staff   7580072 Jun 13 15:57 eta-pkg
-rwxr-xr-x  1 alexander  staff   1863813 Jun 13 15:57 eta-serv.jar
-rw-------  1 alexander  staff        24 Jun 13 15:57 index
Jyothsnasrinivas commented 6 years ago

@lippling Can you try running the command ./gradlew repl and share the output?

lippling commented 6 years ago
./gradlew --no-daemon -q --console plain repl

╭─── Welcome to Eta REPL v0.8.0b2! ────────────────────────╮
│                                                          │
│ :help for help                                           │
│ :exit to exit                                            │
│ :type [expr] for type of expression                      │
│ :kind [type] for kind of type                            │
│ :kind! [type] for kind of simplified type                │
│                                                          │
│ it refers to the last expression                         │
│                                                          │
│ For more details, check out https://eta-lang.org         │
│                                                          │
╰──────────────────────────────────────────────────────────╯

eta: While in operation Call:
Exception: {handle: fd:14}: Eta.REPL.Message.remoteCall: end of file
eta-serv terminated (1)
Error: Unable to access jarfile 

etlas: repl failed for repl-0.
Jyothsnasrinivas commented 6 years ago

@lippling Can you please add the following config to your configuration file which is located at ~/.etlas/config. This will turn on the verbosity and will help us understand the problem.

program-default-options
  eta-options: -v9 -opti-v -optjava-XX:MaxJavaStackTraceDepth=-1

And then share the output of ./gradlew --no-daemon -q --console plain repl.

lippling commented 6 years ago

I attached it as a file, as it's quite long.

log.txt

Jyothsnasrinivas commented 6 years ago

@lippling Thanks for the file. Is this your first time installing Eta/Etlas or do you have a pre-existing installation?

lippling commented 6 years ago

It is not the first time ever. I used it several months ago, but this is the first time with Gradle. Which folders should I delete?

Jyothsnasrinivas commented 6 years ago

Then most likely deleting ~/.eta and ~/.etlas folders and building your project from scratch (which mean running ./gradlew clean ) should fix the problem.

lippling commented 6 years ago

Thanks! It works. 👍

But I have to stop for now.

I tried to use these dependencies:

  compile eta('transformers:0.5.2.0')
  compile eta('bytestring:0.10.8.2')
  compile eta('aeson:1.2.4.0')
  compile eta('text:1.2.3.0')
  compile eta('wai:3.2.1.2')
  compile eta('wai-servlet:0.1.5.1')
  compile eta('wai-servlet-handler-jetty')
  compile eta('servant:0.13.0.1')
  compile eta('servant-docs:0.11.2')
  compile eta('servant-server:0.13.0.1')
  compile eta('http-types:0.12.1')
  compile 'javax.servlet:javax.servlet-api:3.1.0'

And there is a transitive dependency to unix which cannot be built. I couldn't figure out, where it comes from.

jneira commented 6 years ago

@lippling hi!, i am afraid some of those package versions don't have patches to make them works with eta. The set of package versions suitables for eta are in this project: https://github.com/typelead/eta-hackage#supported-packages

Yo can check there that, for example, aeson last usable version in eta is 1.2.3.0. One of the changes applied by those patches is precisely remove the unix dependency (and replacing it with java ffi)

Anyway the error message should tell you what package is failing, could you share the error before fixing it to see how can we improve it?

lippling commented 6 years ago

Ok, I'll have a look at that list. Maybe that solves the Problem.

The error message is:

Failed to build unix-2.7.2.2.
  Build log (
  /Users/alexander/.etlas/logs/eta-0.8.0.2/unix-2.7.2.2-3ca283384ef175df4fd71e2990ef8a0742a408de6fb5ae3f87d05860338c3748.log
  ):
  Configuring library for unix-2.7.2.2..
  Preprocessing library for unix-2.7.2.2..
  etlas: can't find source for System/Posix/Resource in ., dist/build/autogen,
  dist/build/global-autogen
  Process Standard Error:
  etlas: Failed to build unix-2.7.2.2 (which is required by
  servant-server-0.13.0.1). See the build log above for details.

I looked at servant-server, but couldn't find unix there, so my assumption is that it is a transitive dependency.

jneira commented 6 years ago

Mmmm your guess is right, servant-server depends on warp that in turn uses unix and eta-hackage does not have a patch for servant-server-0.13.0.1. There is a working example using servant here: https://github.com/typelead/eta-fib-service. In its cabal file you can see servant-server has no bounds so etlas (and hopefully gradle) will get auto the last suitable version for eta (0.11).

lippling commented 6 years ago

I tested it with the fib code from there and these dependencies:

  compile eta('aeson')
  compile eta('wai-servlet-handler-jetty')
  compile eta('servant-server:0.11')

and got:

Resolving dependencies...
  In order, the following will be built (use -v for more details):
   - wai-servlet-0.1.4.0 (lib) (dependency rebuilt)
   - wai-servlet-handler-jetty-0.1.1.0 (lib) (dependency rebuilt)
  Configuring wai-servlet-0.1.4.0 (lib)...
  Building wai-servlet-0.1.4.0 (lib)...

  Failed to build wai-servlet-0.1.4.0.
  Build log (
  /Users/alexander/.etlas/logs/eta-0.8.0.2/wai-servlet-0.1.4.0-85d103e219cb0cd5025447c26c289d50f219363f671212d7236fefe99a47529b.log
  ):
  Configuring library for wai-servlet-0.1.4.0..
  Preprocessing library for wai-servlet-0.1.4.0..
  Building library for wai-servlet-0.1.4.0..

  [1 of 5] Compiling Network.Wai.Servlet.Request
  src/Network/Wai/Servlet/Request.hs:107:21: error:
      Not in scope: ‘pureJavaWith’
      |
  107 | requestMethod req = pureJavaWith req $ do
      |                     ^^^^^^^^^^^^

[SNIP]

  Process Standard Error:
  etlas: Failed to build wai-servlet-0.1.4.0 (which is required by
  wai-servlet-handler-jetty-0.1.1.0). See the build log above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

Maybe I should have a look at it again in several months.

Thanks for helping me so far.

jneira commented 6 years ago

Ugh, it seems dependency resolution is not working correctly, we have to investigate it. Could you add a explicit dependency to wai-servlet: compile eta('wai-servlet:0.1.5.1')?

I tested it with the fib code from there and these dependencies:

compile eta('aeson') compile eta('wai-servlet-handler-jetty') compile eta('servant-server:0.11')

and got:

Resolving dependencies... In order, the following will be built (use -v for more details):

  • wai-servlet-0.1.4.0 (lib) (dependency rebuilt)
  • wai-servlet-handler-jetty-0.1.1.0 (lib) (dependency rebuilt) Configuring wai-servlet-0.1.4.0 (lib)... Building wai-servlet-0.1.4.0 (lib)...

    Failed to build wai-servlet-0.1.4.0. Build log ( /Users/alexander/.etlas/logs/eta-0.8.0.2/wai-servlet-0.1.4.0-85d103e219cb0cd5025447c26c289d50f219363f671212d7236fefe99a47529b.log ): Configuring library for wai-servlet-0.1.4.0.. Preprocessing library for wai-servlet-0.1.4.0.. Building library for wai-servlet-0.1.4.0..

    [1 of 5] Compiling Network.Wai.Servlet.Request src/Network/Wai/Servlet/Request.hs:107:21: error: Not in scope: ‘pureJavaWith’ | 107 | requestMethod req = pureJavaWith req $ do | ^^^^^^^^^^^^

[SNIP]

Process Standard Error: etlas: Failed to build wai-servlet-0.1.4.0 (which is required by wai-servlet-handler-jetty-0.1.1.0). See the build log above for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

Maybe I should have a look at it again in several months.

Thanks for helping me so far.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/typelead/gradle-eta/issues/22#issuecomment-397618168, or mute the thread https://github.com/notifications/unsubscribe-auth/AADTE4jKEgFQp_A1aLhXYr58nVqe0a5Wks5t87UEgaJpZM4UmY3v .

jneira commented 6 years ago

Well, it turns out that a lower bound on http-types i introduced in wai-servlet broke the projects depending on both servant-server <= 0.11 and wai-servlet. Making a patch for servant-server-0.12 version wich has a suitable range for http-types seems to have corrected the build of eta-fib-example, which depends on both packages, so i think the example of this issue should work (in regards to these dependencies) .

lippling commented 6 years ago

Thanks! It works!

For reference:

Main.hs:

{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators     #-}

-- this does not work, why?
--module Main where

import           Data.Aeson
import           Network.Wai.Servlet.Handler.Jetty
import           Servant
import           Servant.Server

type API = "fibonacci" :> Capture "n" Int :> Get '[JSON] Value

fib :: Int -> Int
fib 0 = 1
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

api :: Proxy API
api = Proxy

server :: Application
server = serve api fibHandler
  where fibHandler n
          | n >= 0
          = return $ object ["n" .= n, "fib" .= fib n]
          | otherwise = throwError $ err412 { errBody = "Precondition Failed: n >= 0" }

main :: IO ()
main = run 9000 server

build.gradle:

plugins {
    id 'com.typelead.eta' version '0.7.2'
    id 'application'
}

repositories {
    mavenCentral()
}

eta {
    version = '0.8.0b2'
    etlasVersion = '1.4.0.0'
}

dependencies {
  compile eta('base:4.8.2.0')

  compile eta('aeson')
  compile eta('wai-servlet-handler-jetty')
  compile eta('servant-server:0.12')
}

When I specify module Main where it compiles fine, but I get:

Exception in thread "main" java.lang.NoClassDefFoundError: main/Main
        at eta.main.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: main.Main
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more

at runtime.

Removing module Main where fixes it.

rahulmutt commented 6 years ago

This is a known bug, see #20. Since it looks like it's working now and the issue you found is tracked, I'll close this issue.