OPAM-SOURCE(1)
π OPAM-SOURCE(1) β opam-source π
okay bestie, welcome to the opam-source page, straight outta the Opam Manual. this is the one that goes and gets you the source. let's go π«Ά
β¨ NAME β¨
opam-source β Get the source of an opam package. π
πΈ SYNOPSIS πΈ
opam source [OPTION]β¦ PACKAGE
π¦ DESCRIPTION π¦
So like, what does it actually do? It downloads the source for a given package into a local directory. that's it, that's the whole vibe. you'd do this for development, for bug fixing, or for documentation purposes. local source on your machine, yours to poke at β¨
π ARGUMENTS π
PACKAGE(required, no cap, you literally cannot skip it) β a package name, and you can tack an optional version constraint on there. π
π OPTIONS π
--dev-repoβ grab the latest version-controlled source instead of the release archive. iykyk, sometimes you want the live repo, not the packaged drop.--dir=DIRβ the directory where the source should get put. your call, bestie. π--no-checksumsβ do not verify the checksum of downloaded archives. this is equivalent to setting$OPAMNOCHECKSUMSto"true". (yes that's the same as the env var, pick your fighter)--no-switchβ choose the package without any consideration for the current switch (or any other switch for that matter) β no installed packages, no pinned packages, none of it. just the package, raw. β¨--pinβ pin the package to the downloaded source. seeopam pinfor the whole story. π--require-checksumsβ reject installation of packages that don't provide a checksum for the upstream archives. this is equivalent to setting$OPAMREQUIRECHECKSUMSto"true". strict queen behavior π
π COMMON OPTIONS π
these ones are common to all commands, so they show up everywhere like that one friend in every group photo. π
--best-effortβ don't fail if all the requested packages can't be installed; just try to install as many as possible. heads up tho: not all external solvers may support this option (recent versions ofaspcudormccsshould). this is equivalent to setting the$OPAMBESTEFFORTenvironment variable.--cli=MAJOR.MINOR(absent=2.6) β use the command-line interface syntax and semantics ofMAJOR.MINOR. it's intended for any persistent use of opam (scripts, blog posts, all of it), and any version of opam in the sameMAJORseries will behave as for the specifiedMINORrelease. fun fact: this flag was not available in opam 2.0, so if you wanna select the 2.0 CLI you have to 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. you can specify this more than once. if--yesor--noare also given, the value of the last--confirm-levelis what counts. this is equivalent to setting$OPAMCONFIRMLEVEL.--criteria=CRITERIAβ specify user preferences for dependency solving for this run. it 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 lives athttp://www.dicosmo.org/Articles/usercriteria.pdf.--cudf=FILENAMEβ debug option, bb: save the CUDF requests sent to the solver toFILENAME-<n>.cudf, where<n>is the n-th call to the solver during the opam run. π§--debugβ print debug messages to stderr. this is equivalent to setting$OPAMDEBUGto"true".--debug-level=LEVELβ like--debug, but you get to pick the debug level (--debugjust sets 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 running a development version), and exit. π--help[=FMT](default=auto) β show this help in formatFMT.FMTmust 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, whether manually throughopam pinor throughopam install DIR. this is equivalent to settingIGNOREPINDEPENDS=true.--json=FILENAMEβ save the results of the opam run into a computer-readable file. if the filename contains the character%, it gets 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. rip, she's gone π--no-auto-upgradeβ when configuring or updating a repository that's 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'll be assumed to be in the older format. it's preferable in any case 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. (no glow-up today π )-q,--quietβ disables--verbose.--root=ROOTβ useROOTas the current root path. this is equivalent to setting$OPAMROOTtoROOT.--safe,--readonlyβ make sure nothing gets automatically updated or rewritten. super useful for calling from completion scripts, for example. it will fail whenever such an operation is needed; it also avoids waiting for locks, skips interactive questions, and overrides the$OPAMDEBUGvariable. this is equivalent to setting the$OPAMSAFEenvironment variable.--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 it to also display commands called internally (e.g.tar,curl,patch, etc.). 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're pointing to. since the source directory is copied as it is, if it isn't clean it may result in an 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".
lowkey that's a lot of flags, but you ate that. π½οΈβ¨ more parts coming, bestie β don't go anywhere π
πΈ ENVIRONMENT πΈ
okay bestie so opam reads a whole bunch of environment variables and honestly they're kind of the cheat codes of the whole thing π Here's the roster. One thing though β if a variable is a boolean, you turn it OFF with "0", "no", "false", or just an empty string, and you turn it ON with "1", "yes", or "true". No in-between, it's giving binary, periodt.
OPAMALLPARENSβ surround all filters with parenthesis. yeah, all of them πOPAMASSUMEDEPEXTSβ see option `--assume-depexts'.OPAMAUTOANSWERβ internal use only. don't touch, she's not for you π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-effort' option is set, and is expected to maximise theopam-query' property in the solution. lowkey a mouthful but she's doing her best π«ΆOPAMBUILDDOCβ Removed in 2.1. gone, deceased, no longer with us πOPAMBUILDTESTβ Removed in 2.1. same vibe, also gone.OPAMCLIβ see option `--cli'.OPAMCOLORβ when set toalwaysornever, sets a default value for the `--color' option.OPAMCONFIRMLEVELβ see option--confirm-level. and bestie, listen: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 report' to 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 given'curl'program. SeeOPAMFETCHfor more options.OPAMDEBUGβ see options--debug' and--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. she digs deep, fr fr βοΈ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.OPAMEXTERNALSOLVERβ see option `--solver'.OPAMFAKEβ see option `--fake'.OPAMFETCHβ specifies how to download files: eitherwget',curl' or a custom command where variables%{url}%,%{out}%,%{retry}%,%{compress}%and%{checksum}%will be replaced. Overrides the'download-command'value 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. more jobs = more slay π₯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βlogdirsets log directory, default is a temporary directory in/tmpOPAMMAKECMDβ 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. and heads up:OPAMNOis ignored if eitherOPAMCONFIRMLEVELorOPAMYESis set. it's giving "she said no but nobody heard her" πOPAMNOAGGREGATEβ withopam admin check, don't aggregate packages.OPAMNOASPCUDβ Deprecated. we don't stan her anymore, move on πOPAMNOAUTOUPGRADEβ disables automatic internal upgrade of repositories in an earlier format to the current one, on'update'or'init'.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-checksums'when available (e.g. for `opam 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. like. do not. π¨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 willcontinue with a warning, iffalsea timeout is an error. Currently only thebuiltin-z3` backend 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. πOPAMSTATUSLINEβ display a dynamic status line showing what's currently going on on the terminal. (one of one ofalways,neverorauto) β yes bestie, "one of" really is written twice, it's iconic actually, we keep it π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). (yep, the double "one of" is back, we love consistency π)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-onOPAMVERSIONLAGPOWERβ do not use. that's it. that's the whole description. girl is not to be touched π«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 π
okay so this part is 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. Plus, blog posts or other documentation can benefit, as it prevents information from becoming stale. no cap, futureproofing is the vibe π¦
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. so yeah, she'll absolutely call you out if you're being weird about it π
The command-line version is selected by using the --cli option or the OPAMCLI environment variable. --cli may be specified morethan once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given. so like, --cli walks in first and OPAMCLI just sits there quietly being the backup dancer π
π EXIT STATUS π
okay bestie listen up, because this is the part where opam tells you exactly how it's feeling when it walks out the door πͺβ¨ Every number here is a whole mood, and you gotta know them all.
β οΈ Exception alert!! As an exception to everything listed below, theexeccommand returns127if the command was not found or couldn't be executed, and returns the command's own exit value otherwise. That's it, that's the exception. π«Ά
0β Success β¨ ortruefor boolean queries. We love a happy ending.1β False. This is what you get when a boolean return value is expected, like when you're running with--check, or for queries likeopam lint.2β Bad command-line arguments π or command-line arguments pointing to an invalid context (e.g. a file that doesn't follow the expected format).5β Not found. You asked for something (package, version, repository, etc.) that justβ¦ could not be found π.10β Aborted. The operation needed confirmation and you β¨did notβ¨ give it.15β Could not acquire the locks required for the operation π.20β There is no solution to the user request. This can be caused by asking to install two incompatible packages, for example. (enemies to lovers but make it dependency resolution π)30β Error in package definition, or other metadata files. Heads up: using--strictraises this error more often.31β Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. This can be a partial error.40β Sync error. Could not fetch some remotes from the network π. This can be a partial error.50β Configuration error. Opam or system configuration doesn't allow the operation, and needs fixing π οΈ.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 π§©.99β Internal error. Something went wrong, likely due to a bug in opam itself π (not you, bestie, it's not your fault).130β User interrupt.SIGINTwas received, generally due to the user pressing Ctrl+C π«£.
and then there's this little cluster of codes, also on the list:
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 even more lore? The docs live at https://opam.ocaml.org/doc π¦
π AUTHORS π
The absolute icons who built this. Show some respect, they ate π β¨
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 π
opam(1)β yeah, the main character. Go read it. iykyk π
π BUGS π
Found something cursed? Check bug reports at https://github.com/ocaml/opam/issues π We love a good issue thread fr fr.
and that's the whole page, bestie!! π This one came from Opam 2.6.1, filed as OPAM-SOURCE(1) β the date line got cut off in the original, so just know it's the version on the tin β¨ Go forth and opam source something iconic πΈπ«Άπ
π¦ 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