将 --reinstall 标志与 cabal-dev 一起使用

发布于 2024-12-05 07:31:51 字数 734 浏览 6 评论 0原文

我正在开发 wxHaskell 库,并希望将我的开发工作与 hackage 的稳定 wxHaskell 分开,我按以下方式使用 cabal-dev

  1. 我从 darcs 获得了 wxHaskell 的源代码;
  2. 因为 wxHaskell 由三个组件组成,所以我使用了 cabal-dev add-source< /code> 添加每一个(wxwxcorewxdirect);
  3. 然后,我可以通过执行 cabal-dev install wx 来安装到沙箱本地包库中,正如预期的那样,检测到依赖项并构建和安装了所有内容。
  4. 最后,我通过使用 ghc -package-conf 指定沙盒包数据库的位置成功运行了我的测试代码。

当我修改 wxHaskell 源代码时,问题就出现了。为了构建和安装更新的代码,我必须使用 cabal-dev install --reinstall ,这是有意义的,因为我不增加版本号;构建发生,我看到“正在安装库...”和“正在注册...”,但我在代码中所做的更改不存在于重新编译的沙箱库中。

我目前的解决办法是删除 cabal-dev 库,并在每次想要重建时重复该过程。

I'm working on the wxHaskell library, and wishing to keep my development work separate from the stable wxHaskell from hackage I'm using cabal-dev in the following manner:

  1. I obtained the source for wxHaskell from darcs;
  2. Because wxHaskell is comprised of three components I used cabal-dev add-source to add each one (wx, wxcore, wxdirect);
  3. I was then able to install into a sandbox local package library by doing cabal-dev install wx, as expected, the dependencies were detected and everything built and installed.
  4. Finally I successfully ran my test code by using ghc -package-conf to specify the location of the sandboxed package database.

The problem comes when I make modifications to the wxHaskell source. In order to build and install the updated code I have to use cabal-dev install --reinstall, which makes sense as I don't increment the version number; the build takes place and I see "Installing library in..." and "Registering..." but the changes I've made in the code aren't present in the recompiled sandbox library.

The work around I have at the moment is to delete the cabal-dev library and repeat the process every time I want to rebuild.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ〆星空下的拥抱 2024-12-12 07:31:51

更新: cabal-install >= 1.18 支持沙箱,并且今后将比 cabal-dev 得到更好的维护。 Cabal-install 还可以更好地支持将 add-source 与沙箱结合使用。以下是 cabal-install 中新沙箱功能的描述: http: //coldwa.st/e/blog/2013-07-30-Cabal-sandbox.html

旧答案:

正如您所发现的,“add-source”是不适合用于积极变化的项目。我不确定那里是否有一个好的解决方案 - 很难跟踪添加源项目的位置(至少没有现有的基础设施),而且我不确定这总是正确的事情。

另一个工作流程可能会为您提供更好的服务 - 只需使用cabal-dev install,指向您希望用于未来开发的沙箱。 Cabal 工具链的最新版本(我指的是 Cabal、cabal-install 和 cabal-dev)允许这种事情:(

$ ls 
wx        wxcore          wxdirect
$ cabal-dev install --sandbox=<path-to-some-sandbox> ./wx ./wxcore ./wxdirect
...

注意:我还没有用 WX 测试过这一点 - 可能会出现我不知道的问题!)

假设一切按预期进行,这会将本地子目录中的三个包安装到指定的沙箱中。更新源仅意味着为更改的项目重新发出 cabal-dev 安装命令。

请记住,您必须自己以正确的顺序发出重复的 cabal-dev 安装命令,或者您必须使用上面的批处理命令相应地更新版本号。

我并不认为这是理想的;)但我认为这比每次删除沙箱都要好。

UPDATE: cabal-install >= 1.18 has support for sandboxes, and will be better maintained than cabal-dev going forward. Cabal-install also has better support for using add-source with sandboxes. Here's a description of the new sandboxing features in cabal-install: http://coldwa.st/e/blog/2013-07-30-Cabal-sandbox.html

Old answer:

As you found, 'add-source' is not meant for use with actively changing projects. I'm not sure that there is a good solution there either - it's difficult to track the location of an add-source'd project (there is no existing infrastructure for that, at least), and I'm not sure that's always the right thing.

Another workflow may serve you better - just use cabal-dev install, pointing to the sandbox you wish to use for future development. Recent versions of the cabal toolchain (by which I mean Cabal, cabal-install and cabal-dev) allow for this sort of thing:

$ ls 
wx        wxcore          wxdirect
$ cabal-dev install --sandbox=<path-to-some-sandbox> ./wx ./wxcore ./wxdirect
...

(Note: I have not tested this with WX - kinks may arise that I'm unaware of!)

Assuming everything goes as expected, that will install the three packages from the local sub directories into the specified sandbox. Updating the source just means re-issuing a cabal-dev install command for the project that changed.

Keep in mind that you must either issue the repeated cabal-dev install commands in the correct order on your own, or you must use the batch command above and update version numbers accordingly.

I make no claims about this being ideal ;) but I think it's better than deleting the sandbox each time.

浅浅淡淡 2024-12-12 07:31:51

经过一番调查,我可以确认这是我对 add-source 的使用产生误解的结果,详见 README,在这里给出(strong是我自己添加的并指出了我的原因误解):


Cabal-dev 还允许您使用未发布的软件包,就像它们一样
使用 cabal-dev add-source 进行黑客攻击。

例如,linux-ptraceposix-waitpid 软件包仅
最近上传到 hackage。之前使用 cabal-dev 来构建
依赖于这两个包的应用程序:

$ ls
linux-ptrace/  myProject/  posix-waitpid/
$ cd myProject
$ cabal-dev add-source ../linux-ptrace ../posix-waitpid
$ cabal-dev install

请注意,cabal-dev add-source 接受源位置列表。

但要小心,因为已添加的包不会
不再与其原始源位置相关。更改为
上面例子中的linux-ptrace源不会被使用
myProject 除非用户使用以下命令发出 cabal-dev add-source
再次访问 linux-ptrace
。这类似于
您现在可以执行的 cabal install 步骤以使项目能够使用
依赖项的更改。

After some investigation I can confirm that this is a result of my misunderstanding regarding the usage of add-source, as detailed in "Using a sandbox-local Hackage" section of the README, which is given here (the strong was added by myself and indicates the reason for my misunderstanding):


Cabal-dev also allows you to use un-released packages as though they
were on hackage with cabal-dev add-source.

For example, the linux-ptrace and posix-waitpid packages were only
recently uploaded to hackage. Previously, cabal-dev was used to build
applications that depended on these two packages:

$ ls
linux-ptrace/  myProject/  posix-waitpid/
$ cd myProject
$ cabal-dev add-source ../linux-ptrace ../posix-waitpid
$ cabal-dev install

Note that cabal-dev add-source accepts a list of source locations.

Be careful, however, because packages that have been added are not
tied to their original source locations any more. Changes to the
linux-ptrace source in the above example will not be used by
myProject unless the user issues cabal-dev add-source with the
path to the linux-ptrace source again
. This is similar to the
cabal install step you may do now to enable a project to make use of
changes to a dependency.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文