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

Fails for when OPAMROOT is set to something other than the default directory #197

Closed
leojrfs opened this issue Sep 1, 2021 · 2 comments · Fixed by #198
Closed

Fails for when OPAMROOT is set to something other than the default directory #197

leojrfs opened this issue Sep 1, 2021 · 2 comments · Fixed by #198

Comments

@leojrfs
Copy link

leojrfs commented Sep 1, 2021

When OPAMROOT is set to something other than the default directory, opam-monorepo fails:

[ERROR] Opam has not been initialised, please run `opam init'
opam-monorepo: internal error, uncaught exception:
               OpamStd.OpamSys.Exit(50)
               Raised at file "src/core/opamStd.ml", line 1042, characters 15-29
               Called from file "src/state/opamGlobalState.ml", line 60, characters 4-113
               Called from file "src/state/opamGlobalState.ml", line 185, characters 11-20
               Called from file "cmdliner_term.ml", line 25, characters 19-24
               Called from file "cmdliner.ml", line 33, characters 27-34
               Called from file "cmdliner.ml", line 117, characters 32-39
make: *** [Makefile:61: deps-pull] Error 125

It doesn't seem like monorepo is initialising the opam state in the same way opam does, so the OPAMROOT variable is never read.

@NathanReb
Copy link
Contributor

Thanks for reporting this, good catch!

I'll investigate, it must be just an omission on our part, I basically copied the opam initialization code from another plugin without giving it much more thought.

Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-monorepo that referenced this issue Sep 20, 2021
If not set then OPAM does not set the right path for the OPAM root and
will use the default `~/.opam` no matter what. The OPAM API is
surprising in this regard that even passing the root folder to
`load_defaults` does not actually end up setting the folder.

Closes tarides#197
Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-monorepo that referenced this issue Sep 20, 2021
If not set then OPAM does not set the right path for the OPAM root and
will use the default `~/.opam` no matter what. The OPAM API is
surprising in this regard that even passing the root folder to
`load_defaults` does not actually end up setting the folder.

Closes tarides#197
@Leonidas-from-XIV
Copy link
Member

Leonidas-from-XIV commented Sep 21, 2021

@leojrfs You can try the code in the linked PR, it should fix it. We're aiming to get this upstreamed soon but in the meantime this should solve the issue.

NathanReb added a commit to NathanReb/opam-repository that referenced this issue Oct 12, 2021
CHANGES:

### Fixed

- Fix setting `OPAMROOT` to accept non-default paths (tarides/opam-monorepo#197, tarides/opam-monorepo#198,
  @Leonidas-from-XIV)
- Fix a bug where opam-monorepo would erase the opam cache by upgrading
  opam-libs from `2.1~rc2` to `2.1` (tarides/opam-monorepo#204, @NathanReb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants