OPAM-CONFIG(1)
π OPAM-CONFIG π
okay bestie, welcome to the opam-config page, straight out of the Opam Manual. this is part 1 of 3, so buckle up, we're not done yet β¨
πΈ NAME πΈ
opam-config β Display configuration options for packages.
i know. riveting. but it's actually useful, i promise π«Ά
π SYNOPSIS π
opam config [OPTION]β¦ [COMMAND] [ARG]β¦
π¦ DESCRIPTION π¦
so basically, this command goes digging through your opam state and spills the tea on how to use your installed libraries, how to update your PATH, and how to substitute variables that opam packages use. pretty iconic of it honestly π
but here's the vibe check: apart from opam config env, most of these commands are used by opam internally, and are of limited interest for the casual user. so like. don't stress if you never touch them. iykyk π
π COMMANDS π
envβ Returns the bindings for the environment variables set in the current switch, e.g.PATH, in a format intended to be evaluated by a shell. With-v, add comments documenting the reason or package of origin for each binding. This is most usefully used aseval $(opam config env)to have further shell commands be evaluated in the proper opam context. Can also be accessed throughopam env. β¨ this one is the main character, no cap.revert-envβ Reverts environment changes made by opam, e.g.eval $(opam config revert-env)undoes whateval $(opam config env)did, as much as possible. it's giving "undo button but make it shell" πlist [PACKAGE]...β Without argument, prints a documented list of all available variables. WithPACKAGE, lists all the variables available for these packages.expand STRINGβ Expand variable interpolations in the given stringsubst FILE...β Substitute variables in the given files. The strings%{var}%are replaced by the value of variable var (seevar).reportβ Prints a summary of your setup, useful for bug-reports. πcudf-universe [FILE]β Outputs the current available package universe in CUDF format.pef-universe [FILE]β Outputs the current package universe in PEF format.exec [--] COMMAND [ARG]...β Removed in 2.1, useopam execinstead.set VAR VALUEβ Removed in 2.1, useopam varinstead.unset VARβ Removed in 2.1, useopam varinstead.set-global VAR VALUEβ Removed in 2.1, useopam varinstead.unset-global VARβ Removed in 2.1, useopam varinstead.var VARβ Removed in 2.1, useopam varinstead.
β οΈ bestie. the whole back half of this list got yeeted in 2.1. if you're out here typingopam config set, that's a ghost π». useopam var/opam execand move on. periodt.
π OPTIONS π
--inplace-pathβ When updating thePATHvariable, replace any pre-existing opam path in-place rather than putting the new path in front. This means programs installed in opam that were shadowed will remain so afteropam env. lowkey a glow-up for yourPATHβ it edits in place instead of jumping the queue π--set-rootβ With theenvandexecsubcommands, also sets theOPAMROOTvariable, making sure further calls to opam will use the same root.--set-switchβ With theenvandexecsubcommands, also sets theOPAMSWITCHvariable, making sure further calls to opam will use the same switch as this one.--sexpβ Print environment as an s-expression rather than in shell format--shell=SHELLβ Sets the configuration mode for opam environment appropriate for SHELL. One ofbash,sh,csh,zsh,fish,pwsh,cmdorpowershell. Guessed from the parent processes and the$SHELLvariable by default.
π COMMON OPTIONS π
these ones are common to all commands, so like... collective slay. they show up everywhere π«Ά
--best-effortβ Don't fail if all requested packages can't be installed: try to install as many as possible. Note that not all external solvers may support this option (recent versions ofaspcudormccsshould). This is equivalent to setting$OPAMBESTEFFORTenvironment variable. it's giving "we tried our best" energy πͺ--cli=MAJOR.MINOR(absent=2.6) β Use the command-line interface syntax and semantics of MAJOR.MINOR. Intended for any persistent use of opam (scripts, blog posts, etc.), any version of opam in the same MAJOR series will behave as for the specified MINOR release. The flag was not 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. WHEN must be one ofalways,neverorauto. bestie we are NOT living in a world without color β¨--confirm-level=LEVELβ Confirmation level, LEVEL must 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.
π¨ unsafe-yes is literally right there in the name. it means yes to everything, no questions, no takesies backsies. be so fr before you type that.
--criteria=CRITERIAβ Specify user preferences for dependency solving for this run. Overrides$OPAMCRITERIA,$OPAMFIXUPCRITERIAand$OPAMUPGRADECRITERIA. For details on the supported language, and the external solvers available, seehttp://opam.ocaml.org/doc/External_solvers.html. A general guide to using solver preferences can be found athttp://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 message to stderr. This is equivalent to setting$OPAMDEBUGto"true".--debug-level=LEVELβ Like--debug, but allows specifying the debug level (--debugsets it to1). Equivalent to setting$OPAMDEBUGto a positive integer.
--git-versionβ Print the git version of opam, if set (i.e. you are using a development version), and exit.--help[=FMT](default=auto) β Show this help in format FMT. The value FMT must be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined. hi yes this is the one you're using right now, hello π--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 in 2.1.--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 this 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 this behaviour.-q,--quietβ Disables--verbose. shhhhh π€«--root=ROOTβ Use ROOT as the current root path. This is equivalent to setting$OPAMROOTto ROOT.--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. it's giving "look but don't touch" π§--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. not me flipping this on and getting absolutely cooked by my own config files π--switch=SWITCHβ Use SWITCH as the current compiler switch. This is equivalent to setting$OPAMSWITCHto SWITCH.--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". the way that stacking-vjust keeps revealing more... shiny β¨--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 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.
πΈ heads up bestie: if your working dir is messy, that messiness gets copied as-is and can cause a build failure. clean your room before you invite opam in π
-y,--yesβ Answer yes to all opam yes/no questions without prompting. See also--confirm-level. This is equivalent to setting$OPAMYESto"true".
πΈ that's part 1! keep scrolling, there's more π
ok bestie, this next bit is a BIG one, so hydrate first π
π ENVIRONMENT π
so opam reads a whole bunch of environment variables, and they're basically little vibes you set in your shell to change how opam behaves. π
quick rule for the boolean ones (the yes/no girlies): set them to "0", "no", "false" or the empty string to disable, and "1", "yes" or "true" to enable. periodt. β¨
OPAMALLPARENSβ surround all filters with parenthesis. yes, all of them. π«ΆOPAMASSUMEDEPEXTSβ see option--assume-depexts.OPAMAUTOANSWERβ internal use only. nothing to see here bestie πOPAMAUTOREMOVEβ see remove option--auto-remove.OPAMBESTEFFORTβ see option--best-effort.OPAMBESTEFFORTPREFIXCRITERIAβ sets the string that must be prepended to the criteria when the--best-effortoption is set, and is expected to maximise theopam-queryproperty in the solution.OPAMBUILDDOCβ Removed in 2.1. she's gone, don't look for her πOPAMBUILDTESTβ Removed in 2.1. also gone.OPAMCLIβ see option--cli.OPAMCOLORβ when set toalwaysornever, sets a default value for the--coloroption.OPAMCONFIRMLEVELβ see option--confirm-level.OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO. she's the main character here πOPAMCRITERIAβ specifies user preferences for dependency solving. The default value depends on the solver version, useconfig reportto know the current setting. See also option--criteria.OPAMCUDFFILEβ save the cudf graph tofile-actions-explicit.dot.OPAMCUDFTRIMβ controls the filtering of unrelated packages during CUDF preprocessing.OPAMCURLβ can be used to select a givencurlprogram. SeeOPAMFETCHfor more options.OPAMDEBUGβ see options--debugand--debug-level.OPAMDEBUGSECTIONSβ if set, limits debug messages to the space-separated list of sections. Sections can optionally have a specific debug level (for example,CLIENT:2orCLIENT CUDF:2), but otherwise use--debug-level.OPAMDIGDEPTHβ 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-diron update. Without this variable set, opam would keep them unchanged unless explicitly named on the command-line.OPAMDRYRUNβ see option--dry-run.OPAMEDITORβ sets the editor to use for opam file editing, overrides$EDITORand$VISUAL.OPAMERRLOGLENβ sets the number of log lines printed when a sub-process fails.0to print all. all of them. every last one. πOPAMEXTERNALSOLVERβ 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 file.OPAMFIXUPCRITERIAβ same asOPAMUPGRADECRITERIA, but specific to fixup and reinstall.OPAMIGNOREAVAILABLEβ see install option--ignore-available-on.OPAMIGNORECONSTRAINTSβ see 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 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 backtraces.OPAMLOCKEDβ combination of--lockedand--lock-suffixoptions.OPAMLOGSβ logdir sets log directory, default is a temporary directory in/tmpOPAMMAKECMDβ set the systemmakecommand 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 set. she's got no seniority, sorry πOPAMNOAGGREGATEβ 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-checksumswhen available.OPAMNODEPEXTSβ disables system dependencies handling, see option--no-depexts.OPAMNOENVNOTICEβ Internal.OPAMNOSELFUPGRADEβ see option--no-self-upgradeOPAMPINKINDAUTOβ sets whether version control systems should be detected when pinning to a local path. Enabled by default since1.3.0.OPAMPRECISETRACKINGβ fine grain tracking of directories.OPAMPREPROβ set this tofalseto disable CUDF preprocessing. Less efficient, but might help debugging solver issue.OPAMREPOSITORYTARRINGβ internally store all non-vcs repositories astar.gzfiles (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 repository.OPAMREQUIRECHECKSUMSβ 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-root.OPAMROOTISOKβ 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 only. β οΈ read that again bestie, it literally says unsafe.OPAMSOLVERALLOWSUBOPTIMALβ (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 thebuiltin-z3backend handles this degraded case.OPAMSOLVERTIMEOUTβ change the time allowance of the solver. Default is60.0, set to0for unlimited. Note that all solvers may not support this option.OPAMSOLVERTOLERANCEβ changes the tolerance towards the solver choosing an unoptimized solution (i.e. might pull outdated packages). Typical values range from0.0(best solution known to the solver) to1.0(unoptimized solution). Default is0.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 option.OPAMSTATSβ Removed in 2.4. rip πͺ¦OPAMSTATUSLINEβ display a dynamic status line showing what's currently going on on the terminal. (one of one ofalways,neverorauto)OPAMSTRICTβ fail on inconsistencies (file reading, switch import, etc.).OPAMSWITCHβ see option--switch. Automatically set byopam env --switch=SWITCH --set-switch.OPAMUNLOCKBASEβ see install option--unlock-base.OPAMUPGRADECRITERIAβ specifies user preferences for dependency solving when performing an upgrade. OverridesOPAMCRITERIAin upgrades if both are set. See also option--criteria.OPAMUSEINTERNALSOLVERβ see option--use-internal-solver.OPAMUSEOPENSSLβ Removed in 2.2. πͺ¦OPAMUTF8β use UTF8 characters in output (one of one ofalways,neverorauto). 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. πͺ iconic honestlyOPAMVALIDATIONHOOKβ if set, uses the%{hook}%command to validate an opam repository update.OPAMVERBOSEβ see option--verbose.OPAMVERBOSEONβ see option--verbose-onOPAMVERSIONLAGPOWERβ do not use. π« that's it, that's the whole description, don't use it.OPAMWITHDEVSETUPβ see install option--with-dev-setup.OPAMWITHDOCβ see install option--with-doc.OPAMWITHTESTβ see install option `--with-test.OPAMWORKINGDIRβ see option--working-dir.OPAMYESβ see options--yesand--confirm-level.OPAMYEShas priority overOPAMNOand is ignored ifOPAMCONFIRMLEVELis set.OPAMVAR_varβ overrides the contents of the variablevarwhen substituting%{var}%strings inopamfiles.OPAMVAR_package_varβ overrides the contents of the variablepackage:varwhen substituting%{package:var}%strings inopamfiles.
π₯ CLI VERSION π₯
ok so this part is genuinely important bestie, listen up π’
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.
Although opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface.
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.
ngl the last-one-wins thing is giving "the final girl standing gets the crown" energy π
πͺ EXIT STATUS πͺ
okay so before we get into the numbers, one lil exception to everything below that you need to know: the exec command is a whole different beast. It returns 127 if the command wasn't found or literally could not be executed, and otherwise it just hands you back the command's own exit value. That's it, that's the exec lore. π«Ά
Now the actual codes, bestie, in order:
0β Success π ortruefor boolean queries. Living the dream.1β False. You get this when a boolean return value is expected, like when you're running with--check, or for queries likeopam lint. It's not an error, it's just a no. π2β Bad command-line arguments, or command-line arguments pointing at an invalid context (e.g. a file that doesn't follow the expected format). Basically: the vibes you handed opam were illegible.5β Not found. You asked for something (package, version, repository, etc.) that couldn't be found. It's giving ghosted. π»10β Aborted. The operation needed confirmation and you didn't give it. no confirmation, no service. π15β Could not acquire the locks required for the operation. The locks were giving occupied. π20β There is no solution to the user request. This can happen when you ask to install two incompatible packages, for example. Math said no. π30β Error in package definition, or other metadata files. Also, using--strictraises this error more often. careful with that one π31β Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. Note: this can be a partial error. πΈ40β Sync error. Could not fetch some remotes from the network. Also note: this can be a partial error. π50β Configuration error. Opam or system configuration doesn't allow the operation, and needs fixing. Someone has to go in there and fix it, and that someone is you. β¨60β Solver failure. The solver failed to return a sound answer. It can be due to a broken external solver, or an error in solver configuration. the solver woke up and chose chaos π99β Internal error. Something went wrong, likely due to a bug in opam itself. Not you, babe. It's opam. π130β User interrupt.SIGINTwas received, generally because the user pressed Ctrl+C. that was you. you did that. π
aaaand then there's the second little cluster, the command-line-toolkit-flavoured ones:
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 π
See https://opam.ocaml.org/doc. Go read it, it's giving academic baddie. π
π AUTHORS π
the literal icons who built this, in order, no cap:
- 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>
slay. every single one. π
π¦ SEE ALSO π¦
that's the one, bestie, that's the gateway. πΈ
π BUGS π
Found a bug? Check bug reports at https://github.com/ocaml/opam/issues. Not me reading issue threads at 2am like they're fanfic. π
and that's the whole page, bestie!! you made it to the end of OPAM-CONFIG(1) and honestly? iconic behaviour. π
This lil masterpiece lives in Opam 2.6.1, and its date stamp says OPAM-CONFIG(1) down at the bottom like a lil signature. now go forth and opam config responsibly. mwah. π
β¨π
π¦ 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