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

Sandbox: advise user to launch reinit if updated in opam side #4361

Open
MSoegtropIMC opened this issue Sep 15, 2020 · 10 comments · May be fixed by #4414
Open

Sandbox: advise user to launch reinit if updated in opam side #4361

MSoegtropIMC opened this issue Sep 15, 2020 · 10 comments · May be fixed by #4414

Comments

@MSoegtropIMC
Copy link

As far as I can tell the macOS sandbox script (https://github.com/ocaml/opam/blob/master/src/state/shellscripts/sandbox_exec.sh) is copied to .opam/opam-init/hooks during opam init. If opam is updated, this file is not touched. This has the effect that people have recent versions of opam with a not working sandbox. This might depend on the way how opam is installed and/or updated.

A notable effect of this is that any project build with remake does not build in case the sandbox file is too old. I meanwhile check besides the version of opam some properties of the sandbox script in my meta install scripts.

@rjbou
Copy link
Collaborator

rjbou commented Sep 15, 2020

In order to update sandbox scripts, a reinit is needed : opam init --reinit -ni. It is advised in all release blog posts (at the bottom).

Is the problem occurs even with a reinit?

@MSoegtropIMC
Copy link
Author

Is the problem occurs even with a reinit?

I can't tell immediately - it was an issue reported by a user of my opam based Coq meta build scripts. I will contact the user and try to clarify this.

Is there a way to check which version of opam created or last updated the .opam folder, so that I could check this in my scripts and automatically suggest and run the opam reinit?

I can definitely check if the sandbox script is suitable and suggest the reinit in case it is not.

@rjbou
Copy link
Collaborator

rjbou commented Sep 16, 2020

It is possible if there is changes at opam root (cf. new field opam-version at the top of the .opam/config), but it won't help you about sandbox scripts.
To be sure, by default at each new version of opam, advise to run the reinit command. It also can be run outside any opam new release, to be sure to regenerate scripts. You can also see opam init options to customize the reinit.

@rjbou
Copy link
Collaborator

rjbou commented Sep 16, 2020

Note that there is a fix of -ni option in 2.1.0~alpha.

@rjbou
Copy link
Collaborator

rjbou commented Sep 16, 2020

Something that may help you for integration: in 2.1.0~alpha, we added a hash of sandbox script, to avoid overwriting user's modifications (cf. #4020). That hash (md5) is stored in .opam/opam-init/hooks/sandbox.sh.hash.
You can check that hash with the opam repo one at given version (e.g. for 2.1.0~beta on linux https://github.com/ocaml/opam/blob/2.1.0-beta/src/state/shellscripts/bwrap.sh), and advice a reinit if it differ from the opam version you need. Keep in mind that hashes can differ because of local user modification.

@MSoegtropIMC
Copy link
Author

Thanks for all the hints! I am currently still on opam 2.0.7 (I am a bit limited here since I need Windows support). The way I will proceed for now is that I detect with grep if the sandbox file has certain features I need and if not suggest the opam reinit. I think this situation is anyway quite rare and this method should fix at least 99% of the rare cases.

I think long term it would be best if opam would know on its own of the .opam folder is up to date or needs updating and suggest proper action on common opam commands.

@MSoegtropIMC
Copy link
Author

I can confirm that opam init --reinit --no-setup fixes the script (I run it without -i from my script).

So please feel free to close this issue. I still would recommend to have opam check and report this automatically.

@rjbou
Copy link
Collaborator

rjbou commented Sep 17, 2020

Good to hear!

Opam already have a detection of its internal format changes, but it doesn't applies to sandbox scripts. Another mechanism should be put in place for that, to suggest a reinit in case of obsolete sandbox script.

@MSoegtropIMC
Copy link
Author

Another mechanism should be put in place for that, to suggest a reinit in case of obsolete sandbox script.

Will you create an issue for this or should I or do we keep this issue for this?

@rjbou
Copy link
Collaborator

rjbou commented Sep 22, 2020

we can keep this one, and changing it's name

@rjbou rjbou changed the title macOS sandbox file is not updated when opam is updated Sandbox: advice user to launch reinit if updated in opam side Sep 22, 2020
@rjbou rjbou added this to To do in Feature Wish via automation Sep 22, 2020
@rjbou rjbou changed the title Sandbox: advice user to launch reinit if updated in opam side Sandbox: advise user to launch reinit if updated in opam side Sep 22, 2020
@rjbou rjbou added the AREA: UI label Sep 29, 2020
@rjbou rjbou linked a pull request Nov 4, 2020 that will close this issue
@rjbou rjbou added this to To do in Opam 2.1.x via automation Nov 4, 2020
@rjbou rjbou removed this from To do in Feature Wish Nov 4, 2020
@rjbou rjbou added this to the 2.1.0~beta4 milestone Nov 4, 2020
@rjbou rjbou moved this from To do to In Progress in Opam 2.1.x Nov 4, 2020
@rjbou rjbou linked a pull request Dec 7, 2020 that will close this issue
@dra27 dra27 modified the milestones: 2.1.0~beta4, 2.1.0~beta5 Jan 8, 2021
@rjbou rjbou added this to To do in Feature Wish via automation Feb 26, 2021
@rjbou rjbou removed this from the 2.1.0~rc milestone Feb 26, 2021
@dra27 dra27 added this to the 2.1.1 milestone Mar 12, 2021
@dra27 dra27 removed this from In Progress in Opam 2.1.x Mar 12, 2021
@dra27 dra27 added this to To do in Opam 2.2.0 via automation Jul 8, 2021
@dra27 dra27 removed this from To do in Feature Wish Jul 8, 2021
@rjbou rjbou added this to To do in Opam 2.1.x Jul 30, 2021
@dra27 dra27 modified the milestones: 2.1.1, 2.1.2 Sep 17, 2021
@dra27 dra27 modified the milestones: 2.1.2, 2.1.3 Nov 19, 2021
@rjbou rjbou moved this from To do to In progress in Opam 2.2.0 Dec 23, 2021
@rjbou rjbou modified the milestones: 2.1.3, 2.1.4 Aug 12, 2022
@rjbou rjbou modified the milestones: 2.1.4, 2.1.5 Jan 6, 2023
@dra27 dra27 added this to To do in Opam 2.3 via automation Jan 23, 2023
@dra27 dra27 removed this from In progress in Opam 2.2.0 Jan 23, 2023
@rjbou rjbou removed this from the 2.1.5 milestone Jul 4, 2023
@rjbou rjbou removed this from To do in Opam 2.1.x Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.3
  
To do
Development

Successfully merging a pull request may close this issue.

3 participants