alire
alire copied to clipboard
Docs: Unclear how to use local crate
As a new Alire user - it's not clear to me how to go from:
$ alr init --lib my_lib
$ alr init --bin my_bin
...to actually being able to use my_lib in my_bin. Reading publishing.md, I can see that I need to run:
$ alr publish --tar
Publishing assistant: step 1 of 8: Verify user manifest
The release to be published contains this information:
my_lib=0.1.0-dev: Shiny new project
[...]
Do you want to proceed with this information?
[Y] Yes [N] No (default is No) y
Publishing assistant: step 2 of 8: Prepare remote source archive
warn: Not in a git repository, assuming plain sources.
✓ Source archive created successfully.
Please upload the archive generated at alire/archives/my_lib-0.1.0-dev.tbz2 to its definitive online storage location.
Once you have uploaded the file, enter its URL:
Enter URL> https://example.com/my_lib-0.1.0-dev.tbz2
The URL is: https://example.com/my_lib-0.1.0-dev.tbz2
Is this information correct?
[Y] Yes [N] No (default is Yes) Y
Publishing assistant: step 3 of 8: Verify origin URL
✓ Origin is of supported kind: SOURCE_ARCHIVE
Publishing assistant: step 4 of 8: Verify GitHub infrastructure
✓ User has a GitHub account: player1
error: You must fork the community index to your GitHub account:
error: Please visit https://github.com/alire-project/alire-index and fork the repository.
..but I do not want to use GitHub for a newly created and in development library.
To just try and make something work locally - I was able to take the alire.toml from my_lib, renamed it to my_lib-0.1.0-dev.toml and gave it a fake [origin] section. I then placed it in a local index with the layout of the community index, and run:
$ alr index --add file:///home/user/local-alire/ --name local
It doesn't seem to have copied a file across though:
$ alr with my_lib
Requested changes:
✓ my_lib ~0.1.0-dev (add)
Changes to dependency solution:
+ my_lib 0.1.0-dev (new)
Do you want to proceed?
[Y] Yes [N] No (default is Yes) y
ⓘ Deploying my_lib=0.1.0-dev...
$ alr build
ⓘ Building my_bin/my_bin.gpr...
my_bin_config.gpr:2:06: unknown project file: "my_lib.gpr"
my_bin_config.gpr:2:06: imported by "/home/user/ada/my_bin/config/my_bin_config.gpr"
my_bin_config.gpr:2:06: imported by "/home/user/ada/my_bin/my_bin.gpr"
gprbuild: "/home/user/ada/my_bin/my_bin.gpr" processing failed
$ cp ../my_lib/my_lib.gpr . # I knew this wouldn't work but thought to try anyway
$ alr build
ⓘ Building my_bin/my_bin.gpr...
Setup
[mkdir] object directory for project My_Lib
[mkdir] library directory for project My_Lib
[mkdir] object directory for project My_Bin
[mkdir] exec directory for project My_Bin
my_bin.gpr:2:09: unit "my_bin" cannot belong to several projects
my_bin.gpr:2:09: project "my_bin", "/home/user/ada/my_bin/src/my_bin.adb"
my_bin.gpr:2:09: project "my_lib", "/home/user/ada/my_bin/src/my_bin.adb"
my_bin.gpr:2:09: unit "my_bin_config" cannot belong to several projects
my_bin.gpr:2:09: project "my_bin", "/home/user/ada/my_bin/config/my_bin_config.ads"
my_bin.gpr:2:09: project "my_lib", "/home/user/ada/my_bin/config/my_bin_config.ads"
my_bin.gpr:2:09: warning: there are no sources of language "Ada" in this project
gprbuild: "/home/user/ada/my_bin/my_bin.gpr" processing failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/user/ada/my_bin/my_bin.gpr"] exited with code 4
error: Compilation failed.
Ideally, I think I'd just like to be able to do:
$ alr init --lib my_lib
$ alr init --bin my_bin
$ cd my_bin
$ alr with ../my_lib
You can pin the dependency with alr with --use ../my_lib. This should add the following to your alire.toml file:
[[pins]]
my_lib = { path='../my_lib' }
Btw, when publishing a crate, you don't necessarily have to create and upload a tar file. You can just point to a git commit in a repository. For example:
[origin]
url = "git+https://github.com/onox/json-ada.git"
commit = "d429d7af880ab9ed38d58ac08c1c9a16e7697752"
subdir = "json"
The subdir is only needed in a repository with multiple crates.
Thanks @onox for taking the lead.
I guess we need to improve our docs for this usual case in which you want to start parallel development of a couple of related projects.
Is there a way to specify the manifest to use with a local crate?
In my case, I want to use a custom version of ada-util which contains multiples Alire manifests, like alire.toml, alire-xml.toml, etc.
Is there a way to do something like:
utilada_xml = { path="./ada-util", manifest="alire-xml.toml" }
?
No, there's no way to do that at present. Alire expects a single alire.toml per crate. Even if several crates are maintained in one repository, to actually be usable as a monorepo each crate should have their own alire.toml in a separate folder. Of course these manifests could point to the proper project files elsewhere, but it seems that ada-util doesn't do that.
ada-util seems to be structured in another way. I know that its publishing isn't straightforward. You could try to reorganize the manifests as I said and if it works as expected submit the patch to ada-util.