drom icon indicating copy to clipboard operation
drom copied to clipboard

Novice user experience

Open xldenis opened this issue 1 year ago • 6 comments

I'm just trying out drom for a small project and wanted to open an issue with the various problems / issues I'm encountering. I hope this will be useful for the maintainers.

  1. The README in this project contains no example of the installation / usage of drom. I think a simple: opam install drom; drom new project; drom build example would be great. Could also be on the website homepage.
  2. My drom generated project fails to build with the following error:
drom: Entering directory '/Users/xavier/Code/why3-tools'
# Run eval $(opam env) to update the current shell environment
[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

[ERROR] Package conflict!
  * Missing dependency:
    - ocaml-base-compiler = 4.10.0 | ocaml-system < 4.10.1~ | ocaml-variants < 4.10.1~
    unmet availability conditions: '!(os = "macos" & arch = "arm64")'
    unmet availability conditions, e.g. 'sys-ocaml-version = "4.10.0"'
    unmet availability conditions, e.g. '!(os = "macos" & arch = "arm64")'

No solution found, exiting
Error: Command 'opam install -y ocaml.4.10.0' exited with error code 20

I would have expected drom to set up my project specific opam switch and load it if necessary.

  1. No lockfiles? One of the biggest things I was hoping drom would do is fix one of the major issues with opam by enabling lock files by default but this does not seem to be the case?
  2. No way to specify pinned dependencies in package.toml?

xldenis avatar Mar 06 '23 14:03 xldenis

Thanks for your feedback !

  1. Good advice ! I am going to improve the README.md in a few days with such a simple example.
  2. I don't really understand the error. By default, drom sets up a local Opam switch _opam, but not a local opam installation (it still relies on $HOME/.opam/). Version 4.10.0 of OCaml is not available on macos anymore ?
  3. I didn't know how cargo dealt with lockfiles until recently. It sounds quite easy to implement, I will try in the next day before the official release of 0.9.0.
  4. I think the current way would be to use
[fields]
opam-trailer = """
pin-depends: [...]
"""

lefessan avatar Mar 10 '23 17:03 lefessan

Thanks for your feedback !

  1. Good advice ! I am going to improve the README.md in a few days with such a simple example.

  2. I don't really understand the error. By default, drom sets up a local Opam switch _opam, but not a local opam installation (it still relies on $HOME/.opam/). Version 4.10.0 of OCaml is not available on macos anymore ?

It was probably never available for ARM macs, might I suggest to defaulting for the latest stable ocaml when generating a fresh project? It seems like that should be the correct choice in new projects.

  1. I didn't know how cargo dealt with lockfiles until recently. It sounds quite easy to implement, I will try in the next day before the official release of 0.9.0.

Awesome! This is one of the core features of cargo/bundler to me.

If there were an additional way to prevent any manually installed opam packages from infecting the build that would be ideal (though probably harder).

The core problem I'm hoping to solve is that I should be able to clone a project on any random machine that has installed drom, run drom build and have a working compilation. No missing deps, bad pins etc...

  1. I think the current way would be to use

[fields]

opam-trailer = """

pin-depends: [...]

"""

Do you think it would make sense if the package.toml adopts a similar dependency syntax to rust, in cargo you can have

Lib-foo = { version = "blah", git = "url" }

To specify a git dependency. I would imagine that drom handles creating the pin if necessary.

xldenis avatar Mar 10 '23 17:03 xldenis

I think the current way would be to use: opam-trailer = "[...]

Actually, after revisiting the code, I think it does not work for pin-depends. drom creates an opam file gathering information from all the other opam files to install the dependencies, so the opam-trailer is not considered.

Clearly, the solution is around what you propose, Lib-foo = { version = "blah", git = "url" } that would generate the corresponding pin-depend in the opam files.

lefessan avatar Mar 10 '23 18:03 lefessan

In the new master version:

  • Lockfiles:

    • opam is always called with --locked to use lockfiles
    • opam lock is called after dependency installation, and a file $PROJECT-deps.opam.locked is created in the root directory. If it is present at the next install (or committed in git), it will be used by opam install --locked
  • For pin-depends, I used libXXX = { pin = "https://..." }, and libXXX = { pin = "...", version = "=VERSION" } for versioned pinning. This should generate pin-depends field in the corresponding opam file.

lefessan avatar Mar 13 '23 10:03 lefessan

Oups, PR not merged yet...

lefessan avatar Mar 13 '23 10:03 lefessan

Now, it was merged :-)

lefessan avatar Mar 13 '23 12:03 lefessan