Package Managers
Each ecosystem's own tool for reading a manifest, writing a lockfile and publishing to a registry, from npm and pip to Cargo and Bundler. Interviewers ask about the one your stack ships with.
on this pageshowhide
explore
- sbtempty
- npm28 questions
- Package Manifest & Semver6 questions
- Install & Lockfile6 questions
- Scripts & Lifecycle6 questions
- Workspaces & Monorepos5 questions
- Registry & Publishing5 questions
- pnpmempty
- Yarnempty
- Pipempty
- Poetryempty
- Condaempty
- Pipenvempty
- uvempty
- pdmempty
- virtualenvempty
- pyenvempty
- PyPIempty
- Bundler18 questions
- Gemfile Sources & Groups6 questions
- Locking & Updating Gems6 questions
- Bundle Exec & Setup6 questions
- RubyGems11 questions
- Gem Command & Paths5 questions
- Gemspec & Publishing6 questions
- RVM5 questions
- Rbenv5 questions
- Composer20 questions
- Manifest & Constraints5 questions
- Lock File & Installs5 questions
- Autoloader Generation5 questions
- Scripts, Plugins & Audits5 questions
- Packagist5 questions
- Cargo64 questions
- Cargo.toml Manifest5 questions
- Dependency Specifications5 questions
- Resolver and Cargo.lock6 questions
- Additive Features5 questions
- Build Profiles5 questions
- Multi-Crate Workspaces4 questions
- Build & Test Commands5 questions
- Lints, Formatting and Docs6 questions
- Build Script Directives6 questions
- Config and Cross-Compiling5 questions
- Publishing & Registries6 questions
- Third-Party Subcommands6 questions
- Crates.ioempty
- .NET CLI17 questions
- Build, Run & Publish6 questions
- Global & Local Tools5 questions
- SDK Pinning & Solutions6 questions
- NuGet16 questions
- PackageReference & Versions5 questions
- Restore, Lock & Audit5 questions
- Pack & Publish6 questions
- Conan15 questions
- Recipes and Generators5 questions
- Profiles and Binaries5 questions
- Versions and Lockfiles5 questions
- vcpkg13 questions
- Manifest Mode4 questions
- Triplets and Ports5 questions
- CMake and Binary Caching4 questions
- Swift Package Manager22 questions
- Manifest and Targets6 questions
- Version Pinning and Updates6 questions
- Build and Command Plugins5 questions
- App Integration and Binaries5 questions
- pub.devempty
- Homebrewempty
questions
239 · 13 sectionsWith npm, why does `npm ci` in a CI job fail right after a teammate adds a dependency to `package.json`, and what fixes it?
basics
~20 snpm ci installs exactly what package-lock.json records and never writes it, so when package.json declares a dependency the lock lacks it exits with an out-of-sync error. Run npm install locally and commit the updated lock.
In an npm project, what is the difference between `dependencies` and `devDependencies`, and what does `npm install --omit=dev` leave out?
basics
~20 sIn package.json, dependencies are packages the code needs at runtime and install for anyone who installs the package; devDependencies are build and test tools. npm install --omit=dev keeps devDependencies off disk while still recording them in the lockfile.
With npm, what does `npm publish` put into a package's tarball by default, and how do you see that file list before publishing?
basics
~20 sWithout a files field, npm publish packs every file in the package folder except what .npmignore (or .gitignore, when there is no .npmignore) and npm's built-in ignores exclude. Run npm pack --dry-run to print the exact list first.
In an npm project, how does `npm run build` run `vite build` when Vite is only a devDependency and not installed globally?
basics
~20 snpm links every command a dependency declares in its bin field into node_modules/.bin, and npm run adds that folder to the PATH it gives each script, so vite resolves to the project's own installed copy.
In an npm project, what does the root package.json `workspaces` field declare, and what does one `npm install` at the root then produce?
basics
~20 sThe root workspaces field lists the folders or globs, such as packages/*, that hold sibling packages. One root npm install symlinks each into the root node_modules by name, hoists shared dependencies there and writes a single root package-lock.json.
With Bundler, why can a bare `rake test` load different gem versions than `bundle exec rake test`, and what does `bundle exec` change?
basics
~20 sA bare rake starts through RubyGems, which activates the newest installed rake, not the one Gemfile.lock pins. bundle exec runs Bundler.setup first, so the command sees only the locked versions and only the bundle's gems.
In a Gemfile, what versions does `gem "rack", "~> 3.1"` accept, and how do `"~> 3.1.4"`, `">= 3.1"` and a bare `"3.1.4"` differ?
basics
~20 sIn a Gemfile, ~> 3.1 is the pessimistic operator: at least 3.1 and below 4.0. ~> 3.1.4 allows 3.1.4 up to below 3.2, >= 3.1 has no upper bound at all, and a bare "3.1.4" means exactly = 3.1.4.
With Bundler, what is the difference between `bundle install` and `bundle update` when a committed Gemfile.lock already exists?
basics
~20 sbundle install installs exactly the versions Gemfile.lock records and re-resolves only gems whose Gemfile entry changed. bundle update deliberately unlocks the named gems, or every gem with --all, and moves them to the newest versions the Gemfile allows.
In Ruby with Bundler, what is the difference between `require "bundler/setup"` and `Bundler.require`, and how do group arguments change each?
basics
~20 srequire "bundler/setup" calls Bundler.setup, which puts the locked gems of all installed groups on the load path but loads none. Bundler.require runs setup and then requires every gem of the named groups, :default when called without arguments.
In a Gemfile, what does putting gems inside `group :test do ... end` declare, and what does `require: false` on a gem change?
basics
~20 sA group labels gems (ungrouped ones are in :default) so installs and Bundler.setup can include or skip them, yet every group still resolves into one Gemfile.lock. require: false keeps the gem installed and loadable but stops Bundler.require from requiring it automatically.
In RubyGems 4, what do gem install, gem list, gem update and gem uninstall do, and does gem update remove the older version?
basics
~20 sgem install puts a gem and its runtime dependencies into GEM_HOME, gem list shows installed versions, gem update adds the newest version beside the old one, and gem uninstall removes a version. Only gem cleanup or uninstall deletes old versions.
In RubyGems, what is a .gemspec file, which fields must it set, and what does gem build produce from it?
basics
~10 sA .gemspec is Ruby code that builds a Gem::Specification: name, version, summary, authors, files, require_paths and dependencies. gem build validates it and packages the listed files into name-version.gem, the file gem push uploads.
In RubyGems, what is the difference between GEM_HOME and GEM_PATH, and where does gem install --user-install put gems?
basics
~10 sGEM_HOME is the single directory gem install writes into; GEM_PATH is the list of directories RubyGems searches for installed gems, and GEM_HOME is always part of it. --user-install writes to Gem.user_dir, such as ~/.gem/ruby/4.0.0.
In a RubyGems gemspec, what is the difference between add_dependency and add_development_dependency, and what goes wrong if you mix them up?
basics
~20 sadd_dependency declares a runtime dependency, installed and activated with your gem. add_development_dependency declares a tool needed only to work on the gem; gem install skips it unless --development is given, and it is never activated.
When you publish version 1.0 of a gem with gem push, how do RubyGems API keys, MFA and --otp work, and which gemspec metadata hardens the release?
basics
~20 sgem push uploads a built .gem using an API key from gem signin or GEM_HOST_API_KEY. With MFA enabled, the server demands a one-time code passed via --otp or GEM_HOST_OTP_CODE. Metadata rubygems_mfa_required and allowed_push_host harden pushes.
With RVM, what do `rvm install 4.0.7`, `rvm use 4.0.7` and `rvm use 4.0.7 --default` each do, and which one survives a new terminal?
basics
~20 srvm install downloads a prebuilt Ruby or compiles one into ~/.rvm/rubies; rvm use switches only the current shell by rewriting PATH and the gem variables; adding --default also records it as the default alias that every new shell loads.
Why did many Ruby teams move from RVM to rbenv, and what exactly changes for a project when they do?
basics
~20 sRVM hooks cd, sources shell code into every session, manages gemsets and system packages, and last tagged 1.29.12 in 2021; rbenv just selects a Ruby and leaves gems to Bundler. Migrating keeps .ruby-version and drops .rvmrc, .ruby-gemset and RVM.
On an inherited server set up with RVM gemsets, a cron job running `cd /srv/billing && bundle exec rake invoices:send` uses the wrong Ruby, though it works over SSH; why, and how do you fix it?
basics
~20 sRVM's selection is environment state set by a shell function your SSH login shell sources; cron's minimal shell never loads it, so no cd hook and no gemset. Use RVM wrappers, rvm in DIR do, or rvm cron setup.
In RVM, what is a gemset, how do `rvm use 4.0.7@billing --create` and the `@global` gemset work together, and where do new gems go?
basics
~20 sA gemset is a named gem directory attached to one installed Ruby. rvm use 4.0.7@billing --create creates and selects ~/.rvm/gems/ruby-4.0.7@billing; new gems install there, while gems in that Ruby's @global gemset stay visible to it.
When you `cd` into a project, how does RVM choose the Ruby and gemset, and why must a `.rvmrc` be trusted first?
basics
~20 sRVM's cd hook walks up from the new directory and loads the first project file it finds, with .rvmrc checked before .ruby-version. A .rvmrc is shell code sourced into your shell, so RVM asks before running it; .ruby-version is plain data.
With rbenv, how do you install a new Ruby version and pin it for one project, and what does each command write to disk?
basics
~10 sRun rbenv install 4.0.7 (supplied by the ruby-build plugin) to build Ruby into ~/.rbenv/versions/4.0.7, then rbenv local 4.0.7 in the project to write .ruby-version; rbenv global writes the machine default to ~/.rbenv/version.
How do rbenv shims route a ruby or bundle call to the right Ruby version, and when must you run rbenv rehash?
basics
~10 srbenv puts ~/.rbenv/shims first on PATH; each shim is a small script that runs rbenv exec, which resolves the selected version and execs that version's executable. rbenv rehash regenerates shims when new executables appear.
In what order does rbenv decide which Ruby version is active, and how do rbenv shell, local and global map onto that order?
basics
~20 srbenv takes RBENV_VERSION first (set by rbenv shell), then the nearest .ruby-version found walking up from the current directory (written by rbenv local), then ~/.rbenv/version (written by rbenv global), and otherwise uses the system Ruby.
Why is rbenv called the lighter alternative to RVM, and how do you isolate gems per project when rbenv has no gemsets?
basics
~20 srbenv only prepends a shims directory to PATH and resolves the version on each command, without wrapping cd or loading heavy shell functions. It has no gemsets: each installed Ruby has its own gem directory, and Bundler's lockfile isolates each project.
A project's .ruby-version pins 4.0.7 under rbenv, yet a newly opened terminal runs the system Ruby there; how do you diagnose and fix it?
basics
~20 sCheck that ~/.rbenv/shims comes first on PATH with type -a ruby; usually the rbenv init line sits in a startup file that shell never reads, or a later PATH edit wins. Then run rbenv version to spot a stray RBENV_VERSION.
In a composer.json, how do you configure psr-4 autoloading for your own code, and what does requiring vendor/autoload.php give you?
basics
~20 sMap a namespace prefix to a directory under autoload.psr-4, for example "App\": "src/", then require vendor/autoload.php once at the entry point. That file registers Composer's class loader for your code and every dependency, and includes any files entries.
In Composer, what is the difference between composer install and composer update, and which one should a deploy run?
basics
~10 scomposer install installs the exact versions in composer.lock; composer update re-resolves composer.json's constraints, rewrites composer.lock with the newest allowed versions, then installs. Deploys and CI run install, production with --no-dev; developers run update deliberately.
In a composer.json, what is the difference between require and require-dev, and when are require-dev packages not installed?
basics
~20 srequire lists packages the code needs at runtime, installed everywhere and passed on to the package's consumers. require-dev lists test and tooling packages; it is root-only, so a dependency's dev list is never installed, and --no-dev builds skip it.
In Composer, what does composer dump-autoload -o change about how classes are found, and why is it for production rather than development?
basics
~20 sdump-autoload -o scans PSR-4 and PSR-0 directories and writes every class into the classmap, so known classes resolve by array lookup, not a filesystem check. It suits production, where code changes only at deploy, not development.
In a composer.json constraint, how does ^1.2 differ from ~1.2, and how do ^1.2.3, ~1.2.3 and ^0.3 behave?
basics
~10 sIn Composer, ^1.2 and ~1.2 are the same range, >=1.2.0 <2.0.0. They differ with three parts: ~1.2.3 means >=1.2.3 <1.3.0 while ^1.2.3 means >=1.2.3 <2.0.0. For 0.x, ^0.3 means >=0.3.0 <0.4.0.
What is Packagist, and what does publishing a first PHP library to it involve?
basics
~20 sPackagist is the public package registry Composer queries by default. To publish, push a repository with a valid composer.json named vendor/name, submit its URL on Packagist, and tag releases; Packagist reads versions from tags and branches.
You pushed tag v1.3.0 of a PHP library on Packagist, but consumers' composer update does not offer 1.3.0; what do you check?
basics
~20 sFirst check whether Packagist re-read the repository, usually a missing hook. Then check whether the tag was skipped for an invalid name, a mismatched version key or missing composer.json. Last, check the consumer's constraint, stability settings and repository order.
How does Packagist turn a Git repository's tags and branches into Composer versions such as 1.2.0, 2.x-dev and dev-main?
basics
~20 sEach valid tag becomes a release version, compared without its leading v, with any -beta or -RC suffix setting stability. Each branch becomes a dev version: 2.x becomes 2.x-dev, other names become dev-name, and extra.branch-alias can map dev-main to 1.0.x-dev.
On Packagist, how do you retire a PHP package by marking it abandoned with a replacement, and what do consumers' Composer runs then show?
basics
~10 sMark the package abandoned, optionally naming a replacement package, rather than deleting it. Existing versions keep installing, but Composer warns that the package is abandoned and suggests the replacement, and composer audit reports it.
Packagist.org serves only public packages; how should a team distribute private PHP packages to its own projects instead?
basics
~20 sKeep private packages off Packagist.org and serve them from a private repository: individual vcs entries for a few packages, a static registry built with Satis, or a hosted private registry. Credentials go in auth.json or environment variables.
With Cargo, what do `cargo build`, `cargo run` and `--release` each do, and where does each one leave the compiled binary?
basics
~10 scargo build compiles the package with the dev profile into target/debug; cargo run does the same build and then executes the binary; --release switches either command to the optimized release profile and target/release.
In a Cargo.toml, which versions may Cargo select for `serde = "1.0.200"`, and why does that line count as a caret requirement?
basics
~10 sA bare version in Cargo is a caret requirement, so serde = "1.0.200" means >=1.0.200, <2.0.0. Cargo may pick any release in that range, normally the newest, and records its pick in Cargo.lock.
In a Rust project's CI job, what do `cargo fmt --check` and `cargo clippy` each verify, and what makes each step fail?
basics
~20 scargo fmt --check runs rustfmt without rewriting files and fails when any file would change. cargo clippy type-checks the crate and runs Clippy's lints; it fails on deny-level lints, while plain warnings pass unless CI promotes them to errors.
In a Cargo.toml [package] table, what do name, version, edition, rust-version and license do, and which key is actually required?
basics
~20 sOnly name is required: it names the package and its default targets. version defaults to 0.0.0, a missing edition falls back to 2015 with a warning, rust-version is the oldest supported toolchain, and license is metadata a registry needs.
In Cargo, what changes when you run `cargo build --release` instead of `cargo build`, and which profile settings cause it?
basics
~20 sPlain cargo build uses the dev profile: opt-level 0, full debug info, debug assertions and overflow checks on, incremental. The --release flag selects the release profile: opt-level 3, no debug info, both checks off, so builds are slower and binaries faster.
With the .NET 10 SDK, what do dotnet build, dotnet run and dotnet publish each produce, and which configuration does each use by default?
basics
~20 sdotnet build compiles into bin/Debug/net10.0, dotnet run builds and then launches the app (also Debug), and dotnet publish writes the deployable set to a publish folder using Release by default for net8.0 and later projects.
What is the difference between the .NET SDK and the .NET runtime, and what do dotnet --info, --list-sdks and --list-runtimes show?
basics
~20 sThe .NET SDK is the toolchain (dotnet CLI, MSBuild, compilers, NuGet, templates) used to build apps; the runtime only runs them. dotnet --list-sdks and --list-runtimes print what is installed, and dotnet --info prints both plus the SDK selected for the current folder.
With the .NET 10 SDK, how do global tools, tool-path tools and local tools differ in where they install and how you invoke them?
basics
~20 sA .NET tool is a console app shipped as a NuGet package; -g installs it per user into ~/.dotnet/tools on PATH, --tool-path into a folder you choose, and a local install records it in a repository's tool manifest, invoked through dotnet.
With the .NET 10 SDK, how do dotnet publish -r, --self-contained, PublishSingleFile and PublishReadyToRun change what you ship for a command-line tool?
basics
~10 s-r picks the target OS and CPU, --self-contained bundles the .NET runtime, PublishSingleFile packs the app into one executable, and PublishReadyToRun precompiles assemblies for faster startup; on net8.0+ a runtime identifier alone stays framework-dependent.
How does global.json select the .NET SDK for a repository, and what happens with version 10.0.100 and no rollForward when only 10.0.400 is installed?
basics
~20 sglobal.json pins the SDK with sdk.version, and without rollForward the policy is patch: use that version or a later patch in the same feature band. With 10.0.100 requested and only 10.0.400 installed, no 10.0.1xx SDK exists, so SDK resolution fails.
With the .NET 10 SDK, what does dotnet pack produce for a class library, and what do PackageId, Version, Authors and IsPackable default to?
basics
~20 sdotnet pack builds the project in Release and writes <PackageId>.<version>.nupkg to bin/Release. PackageId defaults to the assembly name, the version to Version (1.0.0 unless set), Authors to the assembly name, and IsPackable is true except for test projects.
In a .NET project file, what does <PackageReference Include="Serilog" Version="4.4.0" /> ask NuGet for, and how do [4.4.0], [4.0,5.0) and 4.* change it?
basics
~20 sA bare Version="4.4.0" means 4.4.0 or higher, and NuGet restores the lowest version that satisfies it. [4.4.0] pins exactly, [4.0,5.0) bounds the range and still takes its lowest member, and 4.* floats to the highest 4.x.
With the .NET 10 SDK, what does dotnet restore produce, where do the restored packages land, and when would you run dotnet nuget locals?
basics
~20 sdotnet restore resolves the project's package graph, extracts each package once into the global packages folder (~/.nuget/packages by default) and writes obj/project.assets.json for the build. dotnet nuget locals lists or clears that folder and NuGet's other caches.
With the .NET CLI, how do you publish with dotnet nuget push, and what can you do once a nuget.org release is broken?
basics
~20 sdotnet nuget push <file>.nupkg --source <feed> --api-key <key> uploads the package; a version can be pushed only once. nuget.org does not delete packages: you unlist the broken version, which hides it from search but keeps exact-version restores working, and ship a fixed version.
In NuGet's Central Package Management, how would you move the 25 projects of an accounting suite onto one Directory.Packages.props, and which errors catch leftovers?
basics
~20 sAdd a Directory.Packages.props at the repository root with ManagePackageVersionsCentrally set to true and one PackageVersion per package, then strip Version from every PackageReference. Restore raises NU1008 for a leftover Version and NU1010 for a reference without a PackageVersion.
In Conan 2, what does conan install produce for a conanfile.txt listing fmt and zlib with the CMakeDeps and CMakeToolchain generators?
basics
~10 sIt resolves the dependency graph, puts matching fmt and zlib binaries in the local cache and writes CMake input files: a config package per dependency, conan_toolchain.cmake and CMakePresets.json. It never compiles your own project.
In Conan 2, how does a requirement like zlib/[>=1.3 <2] resolve, and what do the ~ and ^ range operators mean?
basics
~20 sA bracketed range resolves to the newest matching version, taken from the local cache if one matches there, otherwise from the first remote with a match. ~1.3 means >=1.3 <1.4, ^1.3 means >=1.3 <2, and pre-releases are skipped unless requested.
In Conan 2, what do --build=missing, --build=never, --build="*" and a --build pattern each tell conan install to do?
basics
~20 sWithout --build, conan install never compiles a dependency and fails on a missing binary. --build=missing builds only packages with no usable binary, --build="*" rebuilds everything, a pattern rebuilds matching packages, and --build=never forbids building outright.
In Conan 2, how do settings, options and conf differ, and which of them change a package's package_id?
basics
~20 sSettings are project-wide values such as compiler and build_type; options are per-package switches such as shared; conf configures Conan and its tools. Settings and options a recipe declares enter its package_id, while conf stays out unless tools.info.package_id:confs lists it.
In Conan 2, how do CMakeDeps, CMakeToolchain and the generated conan-release preset hand fmt and zlib to a CMake project?
basics
~10 sCMakeDeps writes a config package per dependency declaring targets such as fmt::fmt; CMakeToolchain writes conan_toolchain.cmake and a conan-release preset that loads it and sets CMAKE_BUILD_TYPE, so plain find_package and target_link_libraries work.
How do you make a CMake project consume vcpkg dependencies, and what does pointing CMAKE_TOOLCHAIN_FILE at vcpkg.cmake do during configure?
basics
~10 sSet CMAKE_TOOLCHAIN_FILE to <vcpkg root>/scripts/buildsystems/vcpkg.cmake on the first configure. During project() it runs vcpkg install for the vcpkg.json, then adds the installed tree to CMake's search paths so find_package finds the libraries.
In vcpkg, what is the difference between manifest mode and classic mode, and what does a project's vcpkg.json declare?
basics
~20 sManifest mode reads the project's vcpkg.json, which lists its dependencies, features and version pins, and installs them into a per-project vcpkg_installed directory. Classic mode installs packages named on the command line into one tree shared by the whole vcpkg instance.
In a vcpkg.json, what does the builtin-baseline field pin, and how does it give every developer and CI agent the same library versions?
basics
~20 sbuiltin-baseline is a commit SHA of the vcpkg registry repository. vcpkg reads versions/baseline.json at that commit and uses each port's version there as its minimum, so every machine resolves the same versions whatever its local vcpkg checkout contains.
In vcpkg, what does a triplet such as x64-windows or arm64-osx define, and which triplet is used when none is given?
basics
~20 sA triplet is a named CMake file that sets the target architecture, system and library and CRT linkage for every port built with it. Without --triplet or VCPKG_DEFAULT_TRIPLET, vcpkg targets the host triplet detected from the machine, such as arm64-osx on arm64 Macs.
In a CMake build using vcpkg.cmake, how is VCPKG_TARGET_TRIPLET chosen, and why must it and the other VCPKG_ settings be fixed before project()?
basics
~20 svcpkg.cmake uses VCPKG_TARGET_TRIPLET if set; otherwise it builds a name like x64-windows or arm64-osx from the generator platform, processor and system. It reads every VCPKG_ setting inside the first project(), so they must be set earlier, and a changed triplet needs a fresh cache.
When you add a Swift package to an iOS app in Xcode, what do you choose, and why can an import still fail?
basics
~20 sYou give Xcode the package's repository URL and a version requirement, then choose which library products to link into which targets. Declaring the package links nothing: importing a module that no linked product brings in fails with No such module.
In a Swift package, what does the `// swift-tools-version:` line in Package.swift control, and what goes wrong when it is set too low or too high?
basics
~20 sThe swift-tools-version comment in Package.swift names the oldest Swift toolchain that can build the package and picks the PackageDescription API the manifest compiles against: too low hides newer manifest APIs, too high locks out older toolchains.
What does Swift Package Manager record in Package.resolved, and why does an app commit it while a library's copy is ignored by its clients?
basics
~20 sPackage.resolved records what resolution chose: for every package in the graph, transitive ones included, its identity, location, commit and, where one applies, version or branch. SwiftPM honours it only for the top-level package, so apps commit it and libraries cannot pin clients.
In a Package.swift manifest, which versions does `.package(url:from:)` let SwiftPM choose, and when would you write `exact:`, `branch:` or `revision:` instead?
basics
~20 sfrom: "1.2.3" lets SwiftPM pick any tagged release from 1.2.3 up to, but not including, 2.0.0. exact: allows one release, branch: follows a branch and revision: freezes one commit; the last two leave versioning behind.
In a Swift package manifest, how do targets map to modules, and what does a library product expose to the packages that depend on it?
basics
~20 sEach SwiftPM target builds one module, by default from Sources/<TargetName>. A library product is the outward-facing unit: it vends the public API of the targets it lists, and other packages depend on products, never on bare targets.