orome
orome

Reputation: 48486

How do I build for GHC 7.10.2 in the container-based infrastructure?

I have a project that requires GHC 7.10.2, so to use Travis CI I must install the required version of GHC myself in a pre-install step.

I currently have this working with

env:
 - CABALVER=1.22 GHCVER=7.10.2

before_install:
 - |
    travis_retry sudo add-apt-repository -y ppa:hvr/ghc
    travis_retry sudo apt-get update
    travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
    export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH

in my .travis.yml; but am limited to using the "legacy" infrastructure because of my use of sudo.

I'd like to take advantage of the new container-based infrastructure, and have followed the migration docs as far as I can, resulting in

sudo: false

env:
 - CABALVER=1.22 GHCVER=7.10.2

addons:
  apt:
    sources:
    - hvr-ghc
    packages:
    - cabal-install-$CABALVER
    - ghc-$GHCVER

before_install:
 - |
    export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH

as what seems to me should be the equivalent of the above. But this proceeds to use the default (7.4) version of GHC, which results in a failed build.

How do I build for Haskell 7.10.2 in the container-based infrastructure? Specifically, what should I have in my .travis.yml?

Upvotes: 2

Views: 109

Answers (2)

Pierre R
Pierre R

Reputation: 216

I suspect you are using language: haskell. Could you try with language: c.

My understanding is that travis does not really support ghc-7.10.x just yet (there are outstanding issues). The workaround is to bypass and install it manually (using the hvr-ghc ppa); hence the language: c instead of haskell.

Another tip. Start by removing env. I am pretty sure it won't work inside your addons. Simply use ghc-7.10.2 and cabal-1.22. Now youraddonsshould work fine. Check your travis log to be sure.

I can confirm the stack tutorial (link by Michael Snoyman) is quite good. But it should work with or without stack.

For reference here is a travis file where I try to minimize the usage of sudo to the strict minimum:

https://github.com/PierreR/language-puppet/blob/450ca249e23300351085d24fd58dcf9f429769d5/.travis.yml

As you see, I still use the old travis infra because I need Ruby2.x with the C header.

Here is kind of the same travis file but without using stack (stack is only useful with caching):

https://github.com/bartavelle/language-puppet/blob/master/.travis.yml

Upvotes: 1

Michael Snoyman
Michael Snoyman

Reputation: 31315

There's an explanation of how to do this with Stack in the guide, you can see a full example at:

https://github.com/commercialhaskell/stack/blob/master/doc/GUIDE.md#travis-with-caching

Upvotes: 1

Related Questions