OPAM-VAR(1)
๐ OPAM-VAR(1) โ Opam Manual, but make it bestie ๐
ok so this is the page for opam-var, bestie, and honestly she's lowkey one of the most useful lil commands in the whole opam friend group. she reads variables, she writes variables, and she absolutely does NOT do expansion. periodt.
โจ NAME โจ
opam-var โ display and update the value associated with a given variable ๐
๐ SYNOPSIS ๐
opam var [--global] [--package=PACKAGE] [OPTION]โฆ [VAR[=[VALUE]]]
๐ฆ DESCRIPTION ๐ฆ
ok so here's the vibe check ๐ธ
- no argument at all โ she lists all the opam variables that are currently defined. a lil inventory, a lil tour of your setup โจ
- you hand her a
VARโ she prints the value associated with thatVAR๐ - anything else โ she sets or updates
VAR's value ๐
If no scope is given, she acts on switch variables by default. main character energy honestly ๐
โ ๏ธ okay this one matters: this command does not perform any variable expansion. like, none. zero. she shows you exactly what's there, no glow-up, no substitutions, no makeover montage ๐
๐ธ ARGUMENTS ๐ธ
VAR[=[VALUE]]โ the whole menu, right here:- if you give her only
VAR, she displays its associated value ๐ - if
VALUEis absent, thenVAR's value gets removed. bye bestie ๐ - otherwise, its value is overwritten โจ
- if you give her only
๐ OPTIONS ๐
--globalโ act on global configuration. the whole entire world, not just your current switch ๐๐--package=PACKAGEโ list all variables defined for the given package ๐ฆ. all of them. no crumbs.
๐ COMMON OPTIONS ๐
these are common to all commands โ so they're basically the group chat that everyone's in. you already know ๐
--best-effortโ don't fail if all the requested packages can't be installed: try to install as many as possible ๐ซถ. ngl, not every external solver may support this (recent versions ofaspcudormccsshould, so if you're on those you're chilling). this is equivalent to setting the$OPAMBESTEFFORTenvironment variable.--cli=MAJOR.MINOR(absent=2.6) โ use the command-line interface syntax and semantics ofMAJOR.MINOR๐ฐ๏ธ. this is intended for any persistent use of opam (scripts, blog posts, etc.), and any version of opam in the sameMAJORseries will behave as for the specifiedMINORrelease. heads up though: the flag wasn't available in opam 2.0, so to select the 2.0 CLI, set theOPAMCLIenvironment variable to2.0instead of using this parameter ๐--color=WHENโ colorize the output ๐จ.WHENmust be one ofalways,neverorauto.--confirm-level=LEVELโ confirmation level ๐ซก.LEVELmust be one ofask,no,yesorunsafe-yes. can be specified more than once. if--yesor--noare also given, the value of the last--confirm-levelis taken into account. this is equivalent to setting$OPAMCONFIRMLEVEL`.--criteria=CRITERIAโ specify your user preferences for dependency solving for this run ๐. overrides$OPAMCRITERIA,$OPAMFIXUPCRITERIAand$OPAMUPGRADECRITERIA. for details on the supported language, and the external solvers available, see http://opam.ocaml.org/doc/External_solvers.html. a general guide to using solver preferences can be found at http://www.dicosmo.org/Articles/usercriteria.pdf ๐--cudf=FILENAMEโ debug option ๐: save the CUDF requests sent to the solver toFILENAME-<n>.cudfwhere<n>is the n-th call to the solver during the opam run.--debugโ print debug messages tostderr๐. this is equivalent to setting$OPAMDEBUGto"true".--debug-level=LEVELโ like--debug, but lets you specify the debug level (--debugsets it to1) ๐โจ. equivalent to setting$OPAMDEBUGto a positive integer.--git-versionโ print the git version of opam, if it's set (i.e. you're using a development version ๐ฉโ๐ป), and exit.--help[=FMT](default=auto) โ show this help in formatFMT๐. the valueFMTmust be one ofauto,pager,grofforplain. withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined.--ignore-pin-dependsโ ignore extra pins required by packages that get pinned, either manually throughopam pinor throughopam install DIR๐. this is equivalent to settingIGNOREPINDEPENDS=true.--json=FILENAMEโ save the results of the opam run in a computer-readable file ๐ค. if the filename contains the character%, it will be replaced by an index that doesn't overwrite an existing file. similar to setting the$OPAMJSONvariable.--noโ answer no to all opam yes/no questions without prompting ๐ . see also--confirm-level. this is equivalent to setting$OPAMNOto"true".--no-aspcudโ removed in2.1๐ (she's gone bestie, no notes)--no-auto-upgradeโ when configuring or updating a repository that is written for an earlier opam version (1.2), opam internally converts it to the current format. this disables that behaviour ๐. note that repositories should define their format version in a'repo'file at their root, or they will be assumed to be in the older format. it is, in any case, preferable to upgrade the repositories manually usingopam admin upgrade [--mirror URL]when possible ๐ซถ--no-self-upgradeโ opam will replace itself with a newer binary found atOPAMROOT/opamif present ๐ณ. this disables that behaviour.-q,--quietโ disables--verbose๐คซ--root=ROOTโ useROOTas the current root path ๐ . this is equivalent to setting$OPAMROOTtoROOT.--safe,--readonlyโ make sure nothing will be automatically updated or rewritten ๐. useful for calling from completion scripts, for example. will fail whenever such an operation is needed; also avoids waiting for locks, skips interactive questions and overrides the$OPAMDEBUGvariable. this is equivalent to set environment variable$OPAMSAFE.--solver=CMDโ specify the CUDF solver to use for resolving package installation problems ๐งฎ. this is either a predefined solver โ this version of opam supportsbuiltin-mccs+lp(),builtin-mccs+glpk,builtin-dummy-z3-solver,builtin-0install,aspcud,mccs,aspcud-old,packupโ or a custom command that should contain the variables%{input}%,%{output}%,%{criteria}%, and optionally%{timeout}%. this is equivalent to setting$OPAMEXTERNALSOLVER.--strictโ fail whenever an error is found in a package definition or a configuration file ๐จ. the default is to continue silently if possible ๐ค--switch=SWITCHโ useSWITCHas the current compiler switch ๐. this is equivalent to setting$OPAMSWITCHtoSWITCH.--use-internal-solverโ disable any external solver, and use the built-in one ๐ก (this requires that opam has been compiled with a built-in solver). this is equivalent to setting$OPAMNOASPCUDor$OPAMUSEINTERNALSOLVER.-v,--verboseโ be more verbose ๐ฃ๏ธ. one-vshows all package commands, repeat to also display commands called internally (e.g.tar,curl,patchetc.). repeating n times is equivalent to setting$OPAMVERBOSEto"n".--versionโ show version information ๐-w,--working-dirโ whenever updating packages that are bound to a local, version-controlled directory, update to the current working state of their source instead of the last committed state, or the ref they are pointing to ๐ฉโ๐ป. as the source directory is copied as it is, if it isn't clean it may result on a opam build failure ๐ญ. this only affects packages explicitly listed on the command-line. it can also be set with$OPAMWORKINGDIR.-y,--yesโ answer yes to all opam yes/no questions without prompting โ . see also--confirm-level. this is equivalent to setting$OPAMYESto"true".
ok that's the crew so far bestie, but there's more where that came fromโฆ keep scrolling, we're not done yet ๐
๐ซถ ENVIRONMENT ๐ซถ
okay bestie, so opam is obsessed with environment variables and honestly? same. here's the whole list, no cap ๐
quick vibe check on booleans first: these lil guys love a yes/no moment. set them to "0", "no", "false" or the empty string to disable ๐, and to "1", "yes" or "true" to enable โจ. that's it, that's the whole system.
OPAMALLPARENSโ wraps all the filters in parentheses ๐OPAMASSUMEDEPEXTSโ go look at the--assume-depextsoption, she spills the tea there ๐OPAMAUTOANSWERโ internal use only, bestie. nothing to see here ๐OPAMAUTOREMOVEโ see the remove option--auto-remove๐งOPAMBESTEFFORTโ see option--best-effort๐ชOPAMBESTEFFORTPREFIXCRITERIAโ sets the string that must be prepended to the criteria whenever the--best-effortoption is on, and it's expected to maximise theopam-queryproperty in the solution ๐OPAMBUILDDOCโ Removed in 2.1 ๐ she's gone girlOPAMBUILDTESTโ Removed in 2.1 ๐ also goneOPAMCLIโ see option--cli๐ฅ๏ธOPAMCOLORโ when you set it to always or never, it sets a default value for the--coloroption ๐OPAMCONFIRMLEVELโ see option--confirm-level. and heads up:OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO๐ she's the main character hereOPAMCRITERIAโ specifies your user preferences for dependency solving โจ the default value depends on the solver version, so runconfig reportto know the current setting. see also option--criteriaOPAMCUDFFILEโ save the cudf graph to file-actions-explicit.dot ๐OPAMCUDFTRIMโ controls the filtering of unrelated packages during CUDF preprocessing โ๏ธOPAMCURLโ use this to select a givencurlprogram ๐ seeOPAMFETCHfor more optionsOPAMDEBUGโ see options--debugand--debug-level๐OPAMDEBUGSECTIONSโ if set, it limits debug messages to the space-separated list of sections ๐ sections can optionally have a specific debug level (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use--debug-levelOPAMDIGDEPTHโ defines how aggressive the lookup for conflicts during CUDF preprocessing is โ๏ธOPAMDOWNLOADJOBSโ sets the maximum number of simultaneous downloads ๐ฅOPAMDROPWORKINGDIRโ overrides packages previously updated with --working-dir on update ๐ without this variable set, opam would keep them unchanged unless explicitly named on the command-lineOPAMDRYRUNโ see option--dry-run๐OPAMEDITORโ sets the editor to use for opam file editing, and it overrides$EDITORand$VISUAL๐OPAMERRLOGLENโ sets the number of log lines printed when a sub-process fails ๐ญ set it to 0 to print all of themOPAMEXTERNALSOLVERโ see option--solver๐งOPAMFAKEโ see option--fake๐ญOPAMFETCHโ specifies how to download files: eitherwget,curlor a custom command where variables%{url}%,%{out}%,%{retry}%,%{compress}%and%{checksum}%will be replaced ๐ overrides thedownload-commandvalue from the main config fileOPAMFIXUPCRITERIAโ same asOPAMUPGRADECRITERIA, but specific to fixup and reinstall ๐ ๏ธOPAMIGNOREAVAILABLEโ see the install option--ignore-available-on๐OPAMIGNORECONSTRAINTSโ see the install option--ignore-constraints-on๐ซOPAMIGNOREPINDEPENDSโ see option--ignore-pin-depends๐OPAMINPLACEBUILDโ see option--inplace-build๐๏ธOPAMJOBSโ sets the maximum number of parallel workers to run โกOPAMJSONโ log json output to the given file (use character%to index the files) ๐๏ธOPAMKEEPBUILDDIRโ see the install option--keep-build-dir๐ฆOPAMKEEPLOGSโ tells opam to not remove some temporary command logs and some backups ๐๏ธ this skips some finalisers and may also help to get more reliable backtracesOPAMLOCKEDโ a combination of the--lockedand--lock-suffixoptions ๐OPAMLOGSโ logdir sets the log directory, default is a temporary directory in/tmp๐ก๏ธOPAMMAKECMDโ set the system make command to use ๐จOPAMMERGEOUTโ merge process outputs, stderr on stdout ๐ซฑOPAMNOโ answer no to any question asked ๐ see options--noand--confirm-level.OPAMNOis ignored if eitherOPAMCONFIRMLEVELorOPAMYESis setOPAMNOAGGREGATEโ withopam admin check, don't aggregate packages ๐งบOPAMNOASPCUDโ Deprecated โ ๏ธOPAMNOAUTOUPGRADEโ disables automatic internal upgrade of repositories in an earlier format to the current one, onupdateorinit๐OPAMNOCHECKSUMSโ enables option --no-checksums when available ๐OPAMNODEPEXTSโ disables system dependencies handling, see option--no-depexts๐ซOPAMNOENVNOTICEโ Internal ๐คซOPAMNOSELFUPGRADEโ see option--no-self-upgrade๐OPAMPINKINDAUTOโ sets whether version control systems should be detected when pinning to a local path ๐ฉท enabled by default since 1.3.0OPAMPRECISETRACKINGโ fine grain tracking of directories ๐ฌOPAMPREPROโ set this to false to disable CUDF preprocessing ๐ค less efficient, but might help debugging solver issueOPAMREPOSITORYTARRINGโ internally store all non-vcs repositories as tar.gz files (by default, http repositories are stored as archive) ๐๏ธ this can be much faster on filesystems that don't cope well with scanning large trees. all operation are done in-memory, no I/O for scanning the repositoryOPAMREQUIRECHECKSUMSโ enables option--require-checksumswhen available (e.g. foropam install) โOPAMRETRIESโ sets the number of tries before failing downloads ๐OPAMREUSEBUILDDIRโ see option--reuse-build-dirโป๏ธOPAMROOTโ see option--root๐ณ this is automatically set byopam env --root=DIR --set-rootOPAMROOTISOKโ don't complain when running as root ๐คซOPAMSAFEโ see option--safe๐ฆบOPAMSHOWโ see option--show๐๏ธOPAMSKIPUPDATEโ see option--skip-updatesโญ๏ธOPAMSKIPVERSIONCHECKSโ bypasses some version checks ๐จ Unsafe, for compatibility testing onlyOPAMSOLVERALLOWSUBOPTIMALโ (defaulttrue) allows some solvers to still return a solution when they reach timeout โฐ while the solution remains assured to be consistent, there is no guarantee in this case that it fits the expected optimisation criteria. iftrue, opam will continue with a warning โ ๏ธ iffalsea timeout is an error. currently only the builtin-z3 backend handles this degraded caseOPAMSOLVERTIMEOUTโ change the time allowance of the solver โ default is 60.0, set to 0 for unlimited. note that all solvers may not support this optionOPAMSOLVERTOLERANCEโ changes the tolerance towards the solver choosing an unoptimized solution (i.e. might pull outdated packages) ๐ typical values range from 0.0 (best solution known to the solver) to 1.0 (unoptimized solution). default is 0.0. this option is useful in case the solver can't find a solution in a reasonable time (see$OPAMSOLVERTIMEOUT). note that all solvers may not support this optionOPAMSTATSโ Removed in 2.4 ๐OPAMSTATUSLINEโ display a dynamic status line showing what's currently going on on the terminal ๐บ (one of always, never or auto)OPAMSTRICTโ fail on inconsistencies (file reading, switch import, etc.) ๐คOPAMSWITCHโ see option--switch๐ automatically set byopam env --switch=SWITCH --set-switchOPAMUNLOCKBASEโ see the install option--unlock-base๐OPAMUPGRADECRITERIAโ specifies user preferences for dependency solving when performing an upgrade โฌ๏ธ overridesOPAMCRITERIAin upgrades if both are set. see also option --criteriaOPAMUSEINTERNALSOLVERโ see option--use-internal-solver๐งฉOPAMUSEOPENSSLโ Removed in 2.2 ๐OPAMUTF8โ use UTF8 characters in output ๐ฆ (one of always, never or auto). by defaultauto, which is determined from the locale)OPAMUTF8MSGSโ use extended UTF8 characters (camels) in opam messages ๐ช impliesOPAMUTF8. this is set by default on macOS only ๐OPAMVALIDATIONHOOKโ if set, uses the%{hook}%command to validate an opam repository update ๐ชOPAMVERBOSEโ see option--verbose๐ฃ๏ธOPAMVERBOSEONโ see option --verbose-on ๐ขOPAMVERSIONLAGPOWERโ do not use ๐OPAMWITHDEVSETUPโ see the install option--with-dev-setup๐งโ๐ปOPAMWITHDOCโ see the install option--with-doc๐OPAMWITHTESTโ see the install option--with-test๐งชOPAMWORKINGDIRโ see option--working-dir๐OPAMYESโ see options--yesand--confirm-level๐ซกOPAMYEShas priority overOPAMNOand is ignored ifOPAMCONFIRMLEVELis setOPAMVAR_varโ overrides the contents of the variable var when substituting%{var}%strings inopamfiles ๐คOPAMVAR_package_varโ overrides the contents of the variable package:var when substituting%{package:var}%strings inopamfiles ๐ค
๐ CLI VERSION ๐
okay so this part is important and i need you to actually listen bestie ๐ซถ
all scripts and programmatic invocations of opam should use --cli ๐ฅ๏ธ in order to ensure that they work seamlessly with future versions of the opam client. additionally, blog posts or other documentation can benefit, as it prevents information from becoming stale ๐ฐ like, future-proofing your whole brand.
although opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface ๐ซก so nobody gets left behind.
since CLI version support was only added in opam 2.1, use OPAMCLI to select 2.0 support (as opam 2.0 will just ignore it) โช and --cli=2.1 for 2.1 (or later) versions, since an environment variable controlling the parsing of syntax is brittle ๐ to this end, opam displays a warning if OPAMCLI specifies a valid version other than 2.0, and also if --cli=2.0 is specified โ ๏ธ
the command-line version is selected by using the --cli option or the OPAMCLI environment variable ๐๏ธ --cli may be specified more than once, where the last instance takes precedence ๐ OPAMCLI is only inspected if --cli is not given. periodt ๐
๐ EXIT STATUS ๐
ok so bestie, real talk: opam tells you what happened through its exit code, and you need to know this because scripts check it. One gloriously chaotic exception first though:
EXCEPTION ALERT โ theexeccommand does NOT play by the rules below. It returns127if the command wasn't found or couldn't be executed, and otherwise it just hands you the command's own exit value. That's it. That's the whole deal. ๐
Now, the main character list:
0โ Success! โจ Ortruefor boolean queries. We love a happy ending.1โ False. It's returned when a boolean return value is expected, like when you run with--check, or for queries likeopam lint. So like, "no ๐" not "oops ๐ญ".2โ Bad command-line arguments, or arguments pointing at an invalid context (for example, a file that doesn't follow the expected format). Basically you typed something cursed.5โ Not found. You asked for something (a package, a version, a repository, etc.) and it simply... wasn't there. ๐ซฅ10โ Aborted. The operation needed confirmation and you didn't give it. No consent, no operation, periodt.15โ Could not acquire the locks required for the operation. Somebody else is holding the door. ๐ช20โ There is no solution to the user request. Classic cause: asking to install two incompatible packages, bestie. The math isn't mathing. ๐งฎ๐30โ Error in package definition, or other metadata files. Heads up: using--strictraises this error more often. So if you turn on strict mode and see30, that's on purpose, not a glitch. ๐31โ Package script error. Some package operations were unsuccessful. Could be an error in the packages, or an incompatibility with your system. Lowkey this one can be a partial error โ like, some of it worked. ๐ญ40โ Sync error. Could not fetch some remotes from the network. Also potentially a partial error, so check what actually made it through. ๐ก50โ Configuration error. Opam or system configuration doesn't allow the operation, and it needs fixing. Girl, you gotta fix the config. ๐ ๏ธ60โ Solver failure. The solver failed to return a sound answer. Either a broken external solver, or an error in the solver configuration. The solver is not ok and honestly neither are we. ๐คฏ99โ Internal error. Something went wrong, and it's likely due to a bug in opam itself. Not your fault for once, bestie. ๐130โ User interrupt.SIGINTwas received, generally because the user pressed Ctrl+C. You did this. We saw you. ๐
And then there's this extra lil set of codes, coming in hot:
0โ on success.123โ on indiscriminate errors reported on standard error.124โ on command line parsing errors.125โ on unexpected internal errors (bugs).
๐ FURTHER DOCUMENTATION ๐
Need more? The docs live at https://opam.ocaml.org/doc. Go read them, they're giving study session energy. ๐โจ
๐ AUTHORS ๐
The icons who built this. Show respect, bestie ๐:
- David Allsopp <david@tarides.com>
- Vincent Bernardoff <vb@luminar.eu.org>
- Raja Boujbel <raja.boujbel@ocamlpro.com>
- Kate Deplaix <kit-ty-kate@exn.st>
- Roberto Di Cosmo <roberto@dicosmo.org>
- Thomas Gazagnaire <thomas@gazagnaire.org>
- Louis Gesbert <louis.gesbert@ocamlpro.com>
- Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
- Anil Madhavapeddy <anil@recoil.org>
- Guillem Rieu <guillem.rieu@ocamlpro.com>
- Ralf Treinen <ralf.treinen@pps.jussieu.fr>
- Frederic Tuong <tuong@users.gforge.inria.fr>
๐ธ SEE ALSO ๐ธ
๐ BUGS ๐
Found a bug? Not you being the main character and finding a whole bug ๐ญ check the bug reports at https://github.com/ocaml/opam/issues and file it there. ๐ซถ
<div align="center">
okay bestie that's the whole page, you ate it, no crumbs ๐
This was Opam 2.6.1, the page is OPAM-VAR(1), and it's dated like every good manpage is. Now go run something iconic. โจ๐ฆ๐
</div>
๐ฆ where this page comes from
- arch rolling: opam 2.6.1-1 ยท LGPL-2.1-only
- fedora 44: opam 2.6.1-1.fc44 ยท LGPL-2.1-only WITH OCaml-LGPL-linking-exception
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms