purescript-contrib / pulp

A build tool for PureScript projects
GNU Lesser General Public License v3.0
444 stars 86 forks source link

Installation instructions broken – dependencies mismatch #265

Closed ejoubaud closed 7 years ago

ejoubaud commented 7 years ago

I just had quite the struggle getting Pulp to run on my OSX machine with npm. Following the installation instructions from the readme, I would run:

npm install -g bower purescript pulp
pulp init
pulp run

and consistently get this error:

Compiling Prelude
Error found:
in module Control.Monad.Eff
at /Users/ejoubaud/src/perso/new/bower_components/purescript-eff/src/Control/Monad/Eff.purs line 36, column 1 - line 36, column 52

  Conflicting definitions are in scope for kind Effect from the following modules:

    Control.Monad.Eff
    Prim

Turns out the problem was with the dependencies versions in the bower.json generated by pulp init:

  "dependencies": {
    "purescript-prelude": "^3.0.0",
    "purescript-console": "^3.0.0"
  },
  "devDependencies": {
    "purescript-psci-support": "^3.0.0"
  }

Those dependencies were all just upgraded 2 days ago to 3.0.0 for Purescript 0.11 and pulp init bower-installs them with unpinned versions. But npm install -g purescript still only installs purescript 0.10.7, which I guess is incompatible with the latest version of those deps versions and causes the crash.

I was able to fix this by downgrading the dependencies, removing bower_components and running a new bower install:

  "dependencies": {
    "purescript-prelude": "^2.5.0",
    "purescript-console": "^2.0.0"
  },
  "devDependencies": {
    "purescript-psci-support": "^2.0.0"
  }

I guess this will somewhat sort itself when purescript 0.11 gets released to npm, but it still reveals a dependency management crack that will cause issues (e.g. with people installing pulp on an old purescript version) and can be quite the turn-off for newcomers. Here are a few options I can think to help resolve this in the future:

  1. pin the bower install calls in pulp init to only install the same versions of purescript-prelude and purescript-console as in pulp's own bowerfile.
  2. make some purescript version/range an npm dependency of pulp (I guess that would be a problem for people using a non-npm purescript)
  3. update the installation instructions to specify a version of purescript in the bower install -g purescript line.
  4. Show a warning on pulp commands when they run on a version of purescript higher than what it or its current dependencies have been tested on (though I guess this would make more sense in the purescript libraries themselves, as perhaps options 2 and 3)

I guess option 1 is the one that makes most sense to me as the root issue here isn't that pulp isn't compatible with 0.11 but rather that gulp init generates a bower.json with unpinned versions that end up incompatible with 0.10.x.

hdgarrood commented 7 years ago

I agree this is not ideal, but I'm not sure about your suggestions. Some observations:

I think the real fix is to get libraries to declare which compiler versions they support, and to take that into account in pulp/psc-package.

masaeedu commented 7 years ago

Is there a workaround for getting this stuff to work without downgrading? If so, could this be mentioned in the Getting Started Guide docs? This was my first time trying PureScript and I immediately had to start shaving yaks.

hdgarrood commented 7 years ago

I wouldn't really call it a workaround; the situation right now is basically that certain versions of libraries only work with certain compiler versions, and for now you have to manually ensure that you're using versions which match up. I expect most libraries will need to be updated for 0.11, in fact, so for now you're best off sticking to 0.10.7, especially if you're new to purescript.

masaeedu commented 7 years ago

Well even if it isn't a workaround, something needs to change on that doc page so that following the instructions there doesn't result in:

  Conflicting definitions are in scope for kind Effect from the following modules:

    Control.Monad.Eff
    Prim

A user who is following the getting started docs is not equipped to understand or resolve this error message.

ejoubaud commented 7 years ago

I expect most libraries will need to be updated for 0.11, in fact, so for now you're best off sticking to 0.10.7

Problem is atm pulp init doesn't give you a working project out of the box if you're on 0.10.7, and the error message on pulp run or pulp psci is not helpful.

ejoubaud commented 7 years ago

Valid points though, I can't think of a good solution, out of the libraries controlling for the versions of purescript they're incompatible with, either through some dependency manager mechanism or a more helpful compile-time error message :(

rintcius commented 7 years ago

I think the real fix is to get libraries to declare which compiler versions they support, and to take that into account in pulp/psc-package.

This would be nice indeed, but I guess it will be quite some work? Maybe it's an idea to split off bower.json (and possibly other templates) into a separate repository and maintain templates per compiler version in that repos? Then on pulp init it can check which psc version is active & generate according to this version by default (possibly with an option to set it explicitly to change the default).

Pauan commented 7 years ago

This is definitely a big problem right now. I believe psc-package will help out a lot with solving this problem, but it's not quite ready for mainstream use yet.

bergmark commented 7 years ago

Would it be possible to use a snapshsot based approach like stackage to provide a consistent set of compiler+packages?

hdgarrood commented 7 years ago

Yes, that's exactly what we're trying to work towards with psc-package. I want to integrate pulp with psc-package eventually but it's a fairly big job and I won't be able to find the time during the semester.

bergmark commented 7 years ago

Great to hear!

cideM commented 7 years ago

It's late, so my comment might not be too helpful but I am one of those beginners. Just wanted to check out PSC real quick and the first wall I hit was about the aforementioned Conflicting definitions are in scope for kind Effect from the following modules:

Instead of downgrading things I just did yarn add global purescript@next

Now purs compile Main.purs from the tutorial gave me something about Control.Monad.Eff.Console not found. Somehow I arrived at the conclusion that a yarn add purescript-console was necessary but in PSC land that should be bower ... and now it's still Module Control.Monad.Eff.Console was not found.

~Back to Elm because why bother.~ I'm sorry, I'm grumpy. I'm going to go to bed now and I am sure there is a solution that I just don't see right now due to me being a total beginner and it being past midnight.

o/

Pauan commented 7 years ago

@cideM I'm very sorry you had a rough time.

PureScript is normally quite stable, but you started at a really bad time, because right now we are in the middle of releasing PureScript 0.11, which breaks a lot of things.

Within a couple of days things should settle down and everything will be stable again for a while. And after psc-package becomes the de-facto way to use libraries, this problem won't happen again.

cideM commented 7 years ago

I am sure things will stabilize soon and you already helped me greatly in Gitter :) so I'll definitely not give up because of a minor hiccup. Thanks for the reassurance

hdgarrood commented 7 years ago

Closing because it doesn't really make sense to track this here, it's a much wider issue than just pulp, and also because the specific issue described no longer happens because all of the tooling now works with psc 0.11 by default.

danielo515 commented 6 years ago

Hello, purs 0.12.0, exactly this problem, but I don't know what versions should I use. My bower.json is like this:

  "dependencies": {
    "purescript-prelude": "^4.0.0",
    "purescript-console": "^4.1.0"
  },
  "devDependencies": {
    "purescript-psci-support": "^4.0.0"
  }

When I try to run pulp build I get the following errors:

Error 1 of 2:

  in module Main
  at src/Main.purs line 4, column 1 - line 4, column 31

    Module Control.Monad.Eff was not found.
    Make sure the source file exists, and that it has been provided as an input to the compiler.

Meta:

$ pulp -v                                                                                                                                                                                             ‹ruby-2.3.0›
Pulp version 12.2.0
purs version 0.12.0 using /usr/local/bin/purs
eviefp commented 6 years ago

There is no pulp release for 0.12 yet, so you're stuck with either making sure you download purs 0.11.x, or not relying on the auto-generated files. When #340 gets merged, pulp init should auto-detect compiler version and generate the correct project files.

danielo515 commented 6 years ago

What do you recommend ? Now I have a project bootstraped with 0.12.0 ready to start learning. Will be hard to migrate once it is released ? Which will be better in terms of learning the language ? Maybe using the latest version does not pay off in terms of frustration.

LiamGoodacre commented 6 years ago

@danielo515 delete your dependencies, kill bower_components, and re-add them at the appropriate version for compiler 0.12. I believe the point here is that the auto-generated files aren't suitable, so it's a matter of replacing them. You could even copy them from https://github.com/purescript-contrib/pulp/pull/340

If you already have your project up and running, I don't believe you will have any issue upgrading pulp once the new version is released - by that time you won't need the auto-generated files.

danielo515 commented 6 years ago

Hello @LiamGoodacre

The thing is that I'm following the PureScript by Example book, and all examples are targeted at version 0.11.x so I ended installing and using that purescript version.

Thanks for your comment anyway

xndlnk commented 6 years ago

well I'm stuck with the same problem. just wanted to start with purescript but its not working. how do I know which versions of purescript, pulp and the dependencies in bower are working together?

jamesabc commented 6 years ago

Another +1, following the Getting Started docs for me on Node 8 + OSX results in Module Control.Monad.Eff.Console was not found.

Steps to reproduce:


npm install -g purescript
npm install -g pulp bower
pulp init
bower install purescript-lists --save
pulp build
danielo515 commented 6 years ago

If anyone wants to follow my steps this should work, at least today:

npm i -g pulp bower purescript@0.11.x
pulp init

However, choosing the libraries from bower is veery tricky. Some of them are on the 4.x which corresponds to PS 0.12, while for some others the version for 0.12 is the library on 5.x The only solution is to install, try, see if it fails, delete bower_components (I hate bower) and install one version less, then REPEAT