Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Create a switch by default when no opam files are present #678

Open
gridbugs opened this issue Jul 28, 2023 · 3 comments
Open

Feature: Create a switch by default when no opam files are present #678

gridbugs opened this issue Jul 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@gridbugs
Copy link

I want to make a test that just installs dune and ocamlformat and runs dune fmt. I don't want to install all the dependencies of my
project - just dune and ocamlformat.

Currently this doesn't work:

jobs:
  fmt:
    runs-on: ubuntu-latest
    steps:
    - name: Set-up OCaml
      uses: ocaml/setup-ocaml@v2
      with:
        ocaml-compiler: 4.14.1
    - uses: actions/checkout@v3
    - run: opam install -y dune ocamlformat

The error is:

Run opam install -y dune ocamlformat
[ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch
'opam install -y dune ocamlformat' failed.
Error: Process completed with exit code 50.

This is part of the log here: https://github.com/gridbugs/llama/actions/runs/5687888861/job/15416935603

I think I could work around this by checking out the project before setting up ocaml but that would waste time downloading dependencies that I don't need for this test.

@psafont
Copy link
Contributor

psafont commented Jul 28, 2023

I think I could work around this by checking out the project before setting up ocaml but that would waste time downloading dependencies that I don't need for this test.

I believe the undesired behaviour can be avoided by disabling pinning:

    - name: Set-up OCaml
      uses: ocaml/setup-ocaml@v2
      with:
        ocaml-compiler: 4.14.1
        opam-pin: false

I use a dedicated workflow for formatting here:
https://github.com/xapi-project/xen-api/blob/master/.github/workflows/format.yml

@smorimoto
Copy link
Member

The next major refactoring will improve the handling of such things, but I've been working on a lot of real world stuff lately and the ETA is still not clear... @psafont's suggestion is the best in the short term.

@smorimoto smorimoto added the enhancement New feature or request label Jul 28, 2023
@gridbugs
Copy link
Author

I tried this but got the same error:

    - name: Set-up OCaml
      uses: ocaml/setup-ocaml@v2
      with:
        ocaml-compiler: 4.14.1
        opam-pin: false
        opam-depext: false

Why would disabling pinning also cause it to create a switch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants