Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void NixRepl::loadFiles()
loadedFiles.clear();

for (auto & i : old) {
notice("Loading '%1%'...", i);
notice("Loading %1%...", PathFmt(i));
loadFile(i);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/eval-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SampleStack : public EvalProfiler
, profileFd([&]() {
AutoCloseFD fd = toDescriptor(open(profileFile.string().c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0660));
if (!fd)
throw SysError("opening file %s", profileFile);
throw SysError("opening file %s", PathFmt(profileFile));
return fd;
}())
, posCache(state)
Expand Down
4 changes: 2 additions & 2 deletions src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,11 @@ void InputScheme::clone(
const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir) const
{
if (std::filesystem::exists(destDir))
throw Error("cannot clone into existing path %s", destDir);
throw Error("cannot clone into existing path %s", PathFmt(destDir));

auto [accessor, input2] = getAccessor(settings, store, input);

Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), destDir));
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), PathFmt(destDir)));

RestoreSink sink(/*startFsync=*/false);
sink.dstPath = destDir;
Expand Down
4 changes: 2 additions & 2 deletions src/libfetchers/git-lfs-fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void Fetch::fetch(
+ "/" + pointer->oid;
std::filesystem::path cachePath = cacheDir / key;
if (pathExists(cachePath)) {
debug("using cache entry %s -> %s", key, cachePath);
debug("using cache entry %s -> %s", key, PathFmt(cachePath));
sink(readFile(cachePath));
return;
}
Expand Down Expand Up @@ -301,7 +301,7 @@ void Fetch::fetch(
sizeCallback(size);
downloadToSink(ourl, authHeader, sink, sha256, size);

debug("creating cache entry %s -> %s", key, cachePath);
debug("creating cache entry %s -> %s", key, PathFmt(cachePath));
if (!pathExists(cachePath.parent_path()))
createDirs(cachePath.parent_path());
writeFile(cachePath, sink.s);
Expand Down
8 changes: 4 additions & 4 deletions src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ static void initRepoAtomically(std::filesystem::path & path, GitRepo::Options op
return;

if (!options.create)
throw Error("Git repository %s does not exist.", path);
throw Error("Git repository %s does not exist.", PathFmt(path));

std::filesystem::path tmpDir = createTempDir(path.parent_path());
AutoDelete delTmpDir(tmpDir, true);
Repository tmpRepo;

if (git_repository_init(Setter(tmpRepo), tmpDir.string().c_str(), options.bare))
throw Error("creating Git repository %s: %s", path, git_error_last()->message);
throw Error("creating Git repository %s: %s", PathFmt(path), git_error_last()->message);
try {
std::filesystem::rename(tmpDir, path);
} catch (std::filesystem::filesystem_error & e) {
Expand All @@ -226,7 +226,7 @@ static void initRepoAtomically(std::filesystem::path & path, GitRepo::Options op
|| e.code() == std::errc::directory_not_empty) {
return;
} else
throw SysError("moving temporary git repository from %s to %s", tmpDir, path);
throw SysError("moving temporary git repository from %s to %s", PathFmt(tmpDir), PathFmt(path));
}
// we successfully moved the repository, so the temporary directory no longer exists.
delTmpDir.cancel();
Expand Down Expand Up @@ -266,7 +266,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>

initRepoAtomically(path, options);
if (git_repository_open(Setter(repo), path.string().c_str()))
throw Error("opening Git repository %s: %s", path, git_error_last()->message);
throw Error("opening Git repository %s: %s", PathFmt(path), git_error_last()->message);

ObjectDb odb;
if (options.packfilesOnly) {
Expand Down
11 changes: 6 additions & 5 deletions src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ std::optional<std::string> readHead(const std::filesystem::path & path)
if (const auto parseResult = git::parseLsRemoteLine(line); parseResult && parseResult->reference == "HEAD") {
switch (parseResult->kind) {
case git::LsRemoteRefLine::Kind::Symbolic:
debug("resolved HEAD ref '%s' for repo '%s'", parseResult->target, path);
debug("resolved HEAD ref '%s' for repo %s", parseResult->target, PathFmt(path));
break;
case git::LsRemoteRefLine::Kind::Object:
debug("resolved HEAD rev '%s' for repo '%s'", parseResult->target, path);
debug("resolved HEAD rev '%s' for repo %s", parseResult->target, PathFmt(path));
break;
}
return parseResult->target;
Expand Down Expand Up @@ -753,9 +753,10 @@ struct GitInputScheme : InputScheme
"\n"
"git -C %2% add \"%1%\"",
path.rel(),
repoPath);
PathFmt(repoPath));
else
return RestrictedPathError("Path '%s' does not exist in Git repository %s.", path.rel(), repoPath);
return RestrictedPathError(
"Path '%s' does not exist in Git repository %s.", path.rel(), PathFmt(repoPath));
};
}

Expand Down Expand Up @@ -848,7 +849,7 @@ struct GitInputScheme : InputScheme
if (!input.getRev())
setWriteTime(localRefFile, now, now);
} catch (Error & e) {
warn("could not update mtime for file %s: %s", localRefFile, e.info().msg);
warn("could not update mtime for file %s: %s", PathFmt(localRefFile), e.info().msg);
}
if (!originalRef && !storeCachedHead(repoUrl.to_string(), shallow, ref))
warn("could not update cached head '%s' for '%s'", ref, repoInfo.locationToArg());
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct PathInputScheme : InputScheme

time_t mtime = 0;
if (!storePath || storePath->name() != "source" || !store.isValidPath(*storePath)) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying %s to the store", absPath));
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying %s to the store", PathFmt(absPath)));
// FIXME: try to substitute storePath.
auto src = sinkToSource(
[&](Sink & sink) { mtime = dumpPathAndGetMtime(absPath.string(), sink, defaultPathFilter); });
Expand Down
7 changes: 4 additions & 3 deletions src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ static DownloadTarballResult downloadTarball_(
url);
}
if (!exists(localPath)) {
throw Error("tarball '%s' does not exist.", localPath);
throw Error("tarball %s does not exist.", PathFmt(localPath));
}
if (is_directory(localPath)) {
if (exists(localPath / ".git")) {
throw Error(
"tarball '%s' is a git repository, not a tarball. Please use `git+file` as the scheme.", localPath);
"tarball %s is a git repository, not a tarball. Please use `git+file` as the scheme.",
PathFmt(localPath));
}
throw Error("tarball '%s' is a directory, not a file.", localPath);
throw Error("tarball %s is a directory, not a file.", PathFmt(localPath));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libflake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,11 @@ lockFlake(const Settings & settings, EvalState & state, const FlakeRef & topRef,
auto s = chomp(diff);
if (lockFileExists) {
if (s.empty())
warn("updating lock file %s", outputLockFilePath);
warn("updating lock file %s", PathFmt(outputLockFilePath));
else
warn("updating lock file %s:\n%s", outputLockFilePath, s);
warn("updating lock file %s:\n%s", PathFmt(outputLockFilePath), s);
} else
warn("creating lock file %s: \n%s", outputLockFilePath, s);
warn("creating lock file %s: \n%s", PathFmt(outputLockFilePath), s);

std::optional<std::string> commitMessage = std::nullopt;

Expand Down
4 changes: 2 additions & 2 deletions src/libmain/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ void initPlugins()
#ifndef _WIN32 // TODO implement via DLL loading on Windows
void * handle = dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL);
if (!handle)
throw Error("could not dynamically open plugin file '%s': %s", file, dlerror());
throw Error("could not dynamically open plugin file %s: %s", PathFmt(file), dlerror());

/* Older plugins use a statically initialized object to run their code.
Newer plugins can also export nix_plugin_entry() */
void (*nix_plugin_entry)() = (void (*)()) dlsym(handle, "nix_plugin_entry");
if (nix_plugin_entry)
nix_plugin_entry();
#else
throw Error("could not dynamically open plugin file '%s'", file);
throw Error("could not dynamically open plugin file %s", PathFmt(file));
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void printVersion(const std::string & programName)
std::cout << "System type: " << settings.thisSystem << "\n";
std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
std::cout << "System configuration file: " << (settings.nixConfDir / "nix.conf") << "\n";
std::cout << "System configuration file: " << (settings.nixConfDir / "nix.conf").string() << "\n";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A regression in 2.33 too

std::cout << "User configuration files: " << concatStringsSep(":", settings.nixUserConfFiles) << "\n";
std::cout << "Store directory: " << settings.nixStore << "\n";
std::cout << "State directory: " << settings.nixStateDir << "\n";
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ Goal::Co DerivationBuildingGoal::buildLocally(
worker.store.toStorePath(i.second.source.string()).first, closure);
} catch (InvalidPath & e) {
} catch (Error & e) {
e.addTrace({}, "while processing sandbox path '%s'", i.second.source);
e.addTrace({}, "while processing sandbox path %s", PathFmt(i.second.source));
throw;
}
for (auto & i : closure) {
Expand Down
11 changes: 6 additions & 5 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ LocalStore::LocalStore(ref<const Config> config)
while (path != root) {
if (std::filesystem::is_symlink(path))
throw Error(
"the path '%1%' is a symlink; "
"the path %1% is a symlink; "
"this is not allowed for the Nix store and its parent directories",
path);
PathFmt(path));
path = path.parent_path();
}
}
Expand Down Expand Up @@ -1301,15 +1301,16 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
for (auto & link : DirectoryIterator{linksDir}) {
checkInterrupt();
auto name = link.path().filename();
printMsg(lvlTalkative, "checking contents of %s", name);
printMsg(lvlTalkative, "checking contents of %s", PathFmt(name));
std::string hash =
hashPath(makeFSSourceAccessor(link.path()), FileIngestionMethod::NixArchive, HashAlgorithm::SHA256)
.first.to_string(HashFormat::Nix32, false);
if (hash != name.string()) {
printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
printError(
"link %s was modified! expected hash %s, got '%s'", PathFmt(link.path()), name.string(), hash);
if (repair) {
std::filesystem::remove(link.path());
printInfo("removed link %s", link.path());
printInfo("removed link %s", PathFmt(link.path()));
} else {
errors = true;
}
Expand Down
18 changes: 10 additions & 8 deletions src/libstore/optimise-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void LocalStore::optimisePath_(
.hash;
}))) {
// XXX: Consider overwriting linkPath with our valid version.
warn("removing corrupted link %s", linkPath);
warn("removing corrupted link %s", PathFmt(linkPath));
warn(
"There may be more corrupted paths."
"\nYou should run `nix-store --verify --check-contents --repair` to fix them all");
Expand All @@ -201,8 +201,10 @@ void LocalStore::optimisePath_(
/* On ext4, that probably means the directory index is
full. When that happens, it's fine to ignore it: we
just effectively disable deduplication of this
file. */
printInfo("cannot link %s to '%s': %s", linkPath, path, strerror(errno));
file.
TODO: Get rid of errno, use error code.
*/
printInfo("cannot link %s to '%s': %s", PathFmt(linkPath), path, strerror(errno));
return;
}

Expand All @@ -216,11 +218,11 @@ void LocalStore::optimisePath_(
auto stLink = lstat(linkPath.string());

if (st.st_ino == stLink.st_ino) {
debug("'%1%' is already linked to %2%", path, linkPath);
debug("%1% is already linked to %2%", PathFmt(path), PathFmt(linkPath));
return;
}

printMsg(lvlTalkative, "linking '%1%' to %2%", path, linkPath);
printMsg(lvlTalkative, "linking %1% to %2%", PathFmt(path), PathFmt(linkPath));

/* Make the containing directory writable, but only if it's not
the store itself (we don't want or need to mess with its
Expand All @@ -245,7 +247,7 @@ void LocalStore::optimisePath_(
systems). This is likely to happen with empty files.
Just shrug and ignore. */
if (st.st_size)
printInfo("%1% has maximum number of links", linkPath);
printInfo("%1% has maximum number of links", PathFmt(linkPath));
return;
}
throw;
Expand All @@ -259,14 +261,14 @@ void LocalStore::optimisePath_(
std::error_code ec;
remove(tempLink, ec); /* Clean up after ourselves. */
if (ec)
printError("unable to unlink %1%: %2%", tempLink, ec.message());
printError("unable to unlink %1%: %2%", PathFmt(tempLink), ec.message());
}
if (e.code() == std::errc::too_many_links) {
/* Some filesystems generate too many links on the rename,
rather than on the original link. (Probably it
temporarily increases the st_nlink field before
decreasing it again.) */
debug("%s has reached maximum number of links", linkPath);
debug("%s has reached maximum number of links", PathFmt(linkPath));
return;
}
throw;
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/profiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void removeFile(const std::filesystem::path & path)
try {
std::filesystem::remove(path);
} catch (std::filesystem::filesystem_error & e) {
throw SysError("removing file '%1%'", path);
throw SysError("removing file %1%", PathFmt(path));
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ void deleteGenerations(
auto [gens, curGen] = findGenerations(profile);

if (gensToDelete.count(*curGen))
throw Error("cannot delete current version of profile %1%'", profile);
throw Error("cannot delete current version of profile %1%", PathFmt(profile));

for (auto & i : gens) {
if (!gensToDelete.count(i.number))
Expand Down Expand Up @@ -282,7 +282,7 @@ void switchGeneration(const std::filesystem::path & profile, std::optional<Gener

void lockProfile(PathLocks & lock, const std::filesystem::path & profile)
{
lock.lockPaths({profile}, fmt("waiting for lock on profile '%1%'", profile));
lock.lockPaths({profile}, fmt("waiting for lock on profile %1%", PathFmt(profile)));
lock.setDeletion(true);
}

Expand Down
6 changes: 3 additions & 3 deletions src/libstore/sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ SQLite::SQLite(const std::filesystem::path & path, SQLiteOpenMode mode)
if (fd) {
struct statfs fs;
if (fstatfs(fd.get(), &fs))
throw SysError("statfs() on '%s'", shmFile);
throw SysError("statfs() on %s", PathFmt(shmFile));
if (fs.f_type == /* ZFS_SUPER_MAGIC */ 801189825 && fdatasync(fd.get()) != 0)
throw SysError("fsync() on '%s'", shmFile);
throw SysError("fsync() on %s", PathFmt(shmFile));
}
} catch (...) {
throw;
Expand All @@ -98,7 +98,7 @@ SQLite::SQLite(const std::filesystem::path & path, SQLiteOpenMode mode)
int ret = sqlite3_open_v2(uri.c_str(), &db, SQLITE_OPEN_URI | flags, vfs);
if (ret != SQLITE_OK) {
const char * err = sqlite3_errstr(ret);
throw Error("cannot open SQLite database '%s': %s", path, err);
throw Error("cannot open SQLite database %s: %s", PathFmt(path), err);
}

if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
Expand Down
12 changes: 6 additions & 6 deletions src/libstore/unix/build/chroot-derivation-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ struct ChrootDerivationBuilder : virtual DerivationBuilderImpl
/* Clean up the chroot directory automatically. */
autoDelChroot = std::make_shared<AutoDelete>(chrootParentDir);

printMsg(lvlChatty, "setting up chroot environment in %1%", chrootParentDir);
printMsg(lvlChatty, "setting up chroot environment in %1%", PathFmt(chrootParentDir));

if (mkdir(chrootParentDir.c_str(), 0700) == -1)
throw SysError("cannot create %s", chrootRootDir);
throw SysError("cannot create %s", PathFmt(chrootRootDir));

chrootRootDir = chrootParentDir / "root";

if (mkdir(chrootRootDir.c_str(), buildUser && buildUser->getUIDCount() != 1 ? 0755 : 0750) == -1)
throw SysError("cannot create %1%", chrootRootDir);
throw SysError("cannot create %1%", PathFmt(chrootRootDir));

if (buildUser
&& chown(
chrootRootDir.c_str(), buildUser->getUIDCount() != 1 ? buildUser->getUID() : 0, buildUser->getGID())
== -1)
throw SysError("cannot change ownership of %1%", chrootRootDir);
throw SysError("cannot change ownership of %1%", PathFmt(chrootRootDir));

/* Create a writable /tmp in the chroot. Many builders need
this. (Of course they should really respect $TMPDIR
Expand Down Expand Up @@ -122,7 +122,7 @@ struct ChrootDerivationBuilder : virtual DerivationBuilderImpl
chmod_(chrootStoreDir, 01775);

if (buildUser && chown(chrootStoreDir.c_str(), 0, buildUser->getGID()) == -1)
throw SysError("cannot change ownership of %1%", chrootStoreDir);
throw SysError("cannot change ownership of %1%", PathFmt(chrootStoreDir));

pathsInChroot = getPathsInSandbox();

Expand Down Expand Up @@ -193,7 +193,7 @@ struct ChrootDerivationBuilder : virtual DerivationBuilderImpl

if (pathExists(target)) {
// There is a similar debug message in doBind, so only run it in this block to not have double messages.
debug("bind-mounting %s -> %s", target, source);
debug("bind-mounting %s -> %s", PathFmt(target), PathFmt(source));
throw Error("store path '%s' already exists in the sandbox", store.printStorePath(path));
}

Expand Down
Loading
Loading