How do you install a specific package version with Spago?

◇◆丶佛笑我妖孽 提交于 2021-02-11 06:06:04

问题


With tools like npm we can install a specific version

npm install foo@1.2.0 

How do you install a specific version using spago install?


回答1:


Firstly, that's not what spago install does. Instead of "adding a package to your project", spago install downloads all packages that are currently referenced in your spago.dhall file.

Secondly, the idea with Spago is that you don't choose a specific package version. Instead what you choose is a "snapshot", which is a collection of certain versions of all available packages that are guaranteed to compile and work together. This is a measure intended to prevent version conflicts and versioning hell (and this is similar to how Haskell stack works)

The snapshot is defined in your packages.dhall file, and then you specify the specific packages that you want to use in spago.dhall. The version for each package comes from the snapshot.

But if you really need to install a very specific version of a package, and you really know what you're doing, then you can modify the snapshot itself, which is described in packages.dhall.

By default your packages.dhall file might look something like this:

let upstream =
      https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.5-20200103/src/packages.dhall sha256:0a6051982fb4eedb72fbe5ca4282259719b7b9b525a4dda60367f98079132f30

let additions = {=}

let overrides = {=}

in  upstream // additions // overrides

This is the default template that you get after running spago new.

In order to override the version for a specific package, add it to the overrides map like this:

let overrides =
  { foo =
      upstream.foo // { version = "v1.2.0" }
  }

And then run spago install. Spago should pull in version 1.2.0 of the foo package for you.



来源:https://stackoverflow.com/questions/62007129/how-do-you-install-a-specific-package-version-with-spago

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!