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

Install via stack by specifying GitHub url fails due to not finding jquery.js #148

Open
Wizek opened this issue Dec 7, 2016 · 6 comments

Comments

@Wizek
Copy link

Wizek commented Dec 7, 2016

While I was trying to try out the fix mentioned in #145 via haskell-stack like so:

packages:
- location:
    git: [email protected]:HeinrichApfelmus/threepenny-gui.git
    commit: master

This error run into me:

[14 of 36] Compiling Foreign.JavaScript.Resources ( /path/to/proj/.stack-work/downloaded/qTls9fnyfSvO/src/Foreign/JavaScript/Resources.hs, /path/to/proj/.stack-work/odir/Foreign/JavaSc
ript/Resources.o )

/path/to/proj/.stack-work/downloaded/qTls9fnyfSvO/src/Foreign/JavaScript/Resources.hs:11:7: error:
    • Exception when trying to run compile-time code:
        ./js/lib/jquery.js: openFile: does not exist (No such file or directory)
      Code: Language.Haskell.TH.Quote.quoteExp include "js/lib/jquery.js"
    • In the quasi-quotation: [include|js/lib/jquery.js|]
Failed, modules loaded: Utils (/path/to/proj/.stack-work/odir/Utils.o), Foreign.JavaScript.Include (/path/to/proj/.stack-work/odir/Foreign/JavaScript/Include.o), Reactive.Threepenny.Me
mo (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Memo.o), Reactive.Threepenny.Monads (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Monads.o), Reactive.Threepenny.PulseLatch
 (/path/to/proj/.stack-work/odir/Reactive/Threepenny/PulseLatch.o), Reactive.Threepenny.Types (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Types.o), [...].

In file included from <command-line>:11:0: error: 

/tmp/ghci23353/cabal_macros.h:536:0: error:
     warning: "CURRENT_COMPONENT_ID" redefined [enabled by default]
     #define CURRENT_COMPONENT_ID "threepenny-gui-0.7.1.0-B0cLq5GyYSPJA2orLiI0sO"
     ^

/tmp/ghci23353/cabal_macros.h:276:0: error:
     note: this is the location of the previous definition
     #define CURRENT_COMPONENT_ID "proj-0.4.4"
     ^
[14 of 37] Compiling Foreign.JavaScript.Resources ( /path/to/proj/.stack-work/downloaded/qTls9fnyfSvO/src/Foreign/JavaScript/Resources.hs, /path/to/proj/.stack-work/odir/Foreign/JavaSc
ript/Resources.o )

/path/to/proj/.stack-work/downloaded/qTls9fnyfSvO/src/Foreign/JavaScript/Resources.hs:11:7: error:
    • Exception when trying to run compile-time code:
        ./js/lib/jquery.js: openFile: does not exist (No such file or directory)
      Code: Language.Haskell.TH.Quote.quoteExp include "js/lib/jquery.js"
    • In the quasi-quotation: [include|js/lib/jquery.js|]
Failed, modules loaded: Utils (/path/to/proj/.stack-work/odir/Utils.o), Foreign.JavaScript.Include (/path/to/proj/.stack-work/odir/Foreign/JavaScript/Include.o), Reactive.Threepenny.Me
mo (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Memo.o), Reactive.Threepenny.Monads (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Monads.o), Reactive.Threepenny.PulseLatch
 (/path/to/proj/.stack-work/odir/Reactive/Threepenny/PulseLatch.o), Reactive.Threepenny.Types (/path/to/proj/.stack-work/odir/Reactive/Threepenny/Types.o), [...].

<no location info>: error:
    Could not find module ‘Foreign.JavaScript’
    It is a member of the hidden package ‘threepenny-gui-0.7.1.0@threepenny-gui-0.7.1.0-B0cLq5GyYSPJA2orLiI0sO’.
Loaded GHCi configuration from /tmp/ghci23353/ghci-script
Prelude Vertex

> :q
Leaving GHCi.

For some reason ./js/lib/jquery.js may be searched for in the wrong working directory.

I was able to work around it by manually downloading:

(cd ./packages; git clone [email protected]:HeinrichApfelmus/threepenny-gui.git)

and changing my stack.yaml to include:

packages:
- location: ./packages/threepenny-gui

Now that I've written all that out it occurred to me that this may be a bug in stack, since I would think that specifying a remote git repo or a local git repo should build rather identically. Or maybe they mostly do except in some edge cases, which threepenny-gui may be exercising here.

At any rate, I've decided to report/document this here in case someone else stumbles into a similar issue, or in case it is rather easy to fix upstream. But it is not pressing for me at the moment since I can just cd into the directory to pull threepenny should I want to.

@HeinrichApfelmus
Copy link
Owner

Yup, looks like an issue with stack to me. It's a tricky corner case: During the Template Haskell phase, an IO action is executed which relies on the current directory.

@ndmitchell
Copy link

If you want an easy way to get jQuery, the Haskell libary js-jquery provides it - and it has the advantages of complying with all the license requirements of upstream distributors like Debian.

@HeinrichApfelmus
Copy link
Owner

HeinrichApfelmus commented Aug 19, 2017

@ndmitchell The js-jquery library is almost what I need! However, I would like to embed the file in the exectuable directly. This way, people can just move the executable around, without any need to worry about external resources. In particular, this simplifies integration with the Electron framework.

@ndmitchell
Copy link

If you use the file-embed library with js-jquery library that should give you everything you need. I have a ticket to write an example in the js-jquery docs.

@ndmitchell
Copy link

Concretely you can get jQuery with:

import Data.FileEmbed
import qualified Data.ByteString as BS
import qualified Language.Javascript.JQuery as JQuery
import Language.Haskell.TH.Syntax

main = print $ BS.take 100 jQueryContents

jQueryContents :: BS.ByteString
jQueryContents = $(embedFile =<< runIO JQuery.file)

HeinrichApfelmus added a commit that referenced this issue Aug 26, 2017
The use of `makeRelativeToProject` might make the
library easier to install with stack in some cases.

Do not use QuasiQuotes, but ordinary TemplateHaskell.
@HeinrichApfelmus
Copy link
Owner

Thanks, @ndmitchell , the file-embed package is very useful. It may actually solve the original problem. @Wizek , does commit f5f7f32 help anything with your original problem?

massudaw pushed a commit to massudaw/threepenny-gui that referenced this issue Aug 28, 2017
The use of `makeRelativeToProject` might make the
library easier to install with stack in some cases.

Do not use QuasiQuotes, but ordinary TemplateHaskell.
massudaw pushed a commit to massudaw/threepenny-gui that referenced this issue Jun 8, 2018
The use of `makeRelativeToProject` might make the
library easier to install with stack in some cases.

Do not use QuasiQuotes, but ordinary TemplateHaskell.
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