如何在另一台计算机上还原Cabal更新。

huangapple go评论115阅读模式
英文:

how to revert cabal update on a different computer

问题

task 1: 在B机器上查看当前的 hackage 状态。

task 2: 在A机器上强制执行 cabal update 到与B机器相同的状态。

英文:

I needed to compile a Haskell program an machine A which failed (for the cryptonite bug, which is not the issue here) but compiled on machine B. The difference was, that I had run cabal update on A but not on B recently. I was compiling with an older state of hackage on B than on A.

To fix the issue I need to

task 1: see which state of hackage I have on B.

task 2: force a cabal update to the same state on A.

I tried to find the required commands with cabal update -h and with search on the web, but could not identify them (and had to revert to use stack lts to progress).

what are the commands for task 1 and 2? with these commands, I could use cabal in a more controlled way and avoid surprises when some package in hackage breaks.

I am using linux (Debian 5.10.179-1 Debian 5.10.179-1) with

cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library 

答案1

得分: 3

虽然我不知道有一个特定的命令来查询时间戳,但有几种方法可以让 cabal 显示它。可能最不侵入性的一种方法是使用 cabal list 命令并启用详细输出:

$ cabal -v --installed list base
读取来自 hackage.haskell.org 的可用软件包...
使用截止到 2022-12-25T11:36:12Z 的历史状态(从最近的指定)
cabal update
索引状态(hackage.haskell.org)= 2022-12-25T11:36:12Z(HEAD = 2023-06-08T09:48:09Z)
* base
    简介:基础库
    默认可用版本:4.17.0.0
    已安装版本:4.17.0.0
    许可证:BSD-3-Clause

一旦您获得了所需的时间戳,您可以在另一台计算机上使用 cabal update 命令时指定它:

$ cabal update 'hackage.haskell.org,2022-12-25T11:36:12Z'
从 hackage.haskell.org 下载最新的软件包列表
hackage.haskell.org 的软件包列表已经是最新的。
索引状态已设置为 2022-12-25T11:36:12Z。
要恢复到以前的状态,请运行:
    cabal v2-update 'hackage.haskell.org,2023-06-08T09:48:09Z'

由于 cabal update 命令会打印旧的索引时间戳,找到时间戳的另一种方法是进行更新,记录下旧的时间戳,然后立即将其恢复。不过,这比只读方法更繁琐一些。

英文:

While I don't know of a command to specifically query the timestamp, there are a few ways of getting cabal to display it. The least invasive one is possibly using cabal list with verbose output:

$ cabal -v --installed list base
Reading available packages of hackage.haskell.org...
Using historical state as of 2022-12-25T11:36:12Z specified from most recent
cabal update
index-state(hackage.haskell.org) = 2022-12-25T11:36:12Z (HEAD =
2023-06-08T09:48:09Z)
* base
    Synopsis: Basic libraries
    Default available version: 4.17.0.0
    Installed versions: 4.17.0.0
    License:  BSD-3-Clause

Once you have the desired timestamp, you can specify it when using cabal update in the other computer:

$ cabal update 'hackage.haskell.org,2022-12-25T11:36:12Z'
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date.
The index-state is set to 2022-12-25T11:36:12Z.
To revert to previous state run:
    cabal v2-update 'hackage.haskell.org,2023-06-08T09:48:09Z'

Since cabal update prints the old index timestamp, another option to find the timestamp would be updating, jotting down the old timestamp, and immediately reverting it. That's a bit more of a hassle than a read-only method, though.

huangapple
  • 本文由 发表于 2023年6月8日 14:43:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76429233.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定