theonedev/onedev · error · ClientException
Package management not enabled for project '${projectPath}'
Error message
Package management not enabled for project '${projectPath}' What it means
Thrown by CargoPackHandler.checkProject when the target project does not have package management enabled. The cargo registry endpoints refuse to operate on a project with isPackManagement() == false, responding with HTTP 406. This is a project-level feature gate, not a permission problem.
Source
Thrown at server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java:386
}
private void writeJson(HttpServletResponse response, Object object) {
response.setContentType(MediaType.APPLICATION_JSON);
try {
objectMapper.writeValue(response.getOutputStream(), object);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private String getLockName(Long projectId, String name) {
return "update-pack:" + projectId + ":" + TYPE + ":" + name;
}
private Project checkProject(Long projectId, boolean needsToWrite) {
var project = projectService.load(projectId);
if (!project.isPackManagement()) {
throw new ClientException(SC_NOT_ACCEPTABLE, "Package management not enabled for project '" + project.getPath() + "'");
} else if (needsToWrite && !SecurityUtils.canWritePack(project)) {
throw new UnauthorizedException("No package write permission for project: " + project.getPath());
} else if (!needsToWrite && !SecurityUtils.canReadPack(project)) {
throw new UnauthorizedException("No package read permission for project: " + project.getPath());
}
return project;
}
@Override
public String getApiKey(HttpServletRequest request) {
return request.getHeader(HttpHeaders.AUTHORIZATION);
}
@Override
public List<String> normalize(List<String> pathSegments) {
return pathSegments;
}
View on GitHub (pinned to d44925c47c)
Solutions
- Enable 'Package Management' in Project -> Settings for the target project
- Confirm the project path/id in your cargo registry config matches an enabled project
- If the project shouldn't host packages, update .cargo/config.toml or publish config to the correct project
Example fix
// .cargo/config.toml — point at a pack-enabled project [registries.onedev] index = "sparse+https://onedev.example.com/~cargo/<correct-project>/index/"
Defensive patterns
Strategy: validation
Validate before calling
// check the project has pack management enabled before configuring cargo // GET /~api/projects/<path> and inspect packManagement, or verify in Project Settings UI
Try / catch
try { execSync('cargo publish'); } catch (e) { if (/Package management not enabled/.test(e.message)) { /* enable in Project Settings */ } } Prevention
- Enable Package Management when creating projects used as registries
- Double-check project path in .cargo/config.toml
- Document registry project setup for teams
When it happens
Trigger: Pointing cargo (e.g. registry index URL or publish config) at a OneDev project whose Package Management setting is off; project id resolved from the URL belongs to a non-pack project.
Common situations: Newly created project where 'Package Management' was never enabled in project settings; pointing CI cargo config at the wrong project path; project copied/imported without the setting.
Related errors
- Time tracking needs to be enabled for the project
- Method Not Allowed
- Invalid publish request body
- No package read permission for project: ${projectPath}
- Unrecognized command:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/d6d8c6ef86d29dd9.
Report an issue: GitHub.