Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure-repo.ts fails before build when a file gets deleted #15685

Open
krassowski opened this issue Jan 23, 2024 · 0 comments
Open

ensure-repo.ts fails before build when a file gets deleted #15685

krassowski opened this issue Jan 23, 2024 · 0 comments

Comments

@krassowski
Copy link
Member

The ensureBranch method checks files for stale references to wrong branch. When removing a file which is under version control jlpm run build will fail on that method with a message like:

> @jupyterlab/repo-top@0.0.1 build:dev
> npm run integrity && npm run build:all && cd dev_mode && npm run build


> @jupyterlab/repo-top@0.0.1 integrity
> node scripts/ensure-buildutils.js && node buildutils/lib/ensure-repo.js

Error: ENOENT: no such file or directory, open 'packages/some-package/src/some-file.ts'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at ~/jupyterlab/buildutils/lib/ensure-repo.js:358:28
    at Array.forEach (<anonymous>)
    at ensureBranch (~/jupyterlab/buildutils/lib/ensure-repo.js:354:11)
    at ensureIntegrity (~/jupyterlab/buildutils/lib/ensure-repo.js:637:28)
    at Object.<anonymous> (~/jupyterlab/buildutils/lib/ensure-repo.js:817:10)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'packages/some-package/src/some-file.ts'
}

This is because until the removal is committed, the file will show up in the output of:

let files = execSync('git ls-tree -r HEAD --name-only')
.toString()
.trim()
.split(/\r?\n/);

and the script then attempts to load it with

// Make the string replacements
files.forEach(filePath => {
if (path.basename(filePath) === 'ensure-repo.ts') {
return;
}
const oldData = fs.readFileSync(filePath, 'utf-8');

Workaround

Commit the removal of the file

Future solution

We could either:

Tohughts?

@krassowski krassowski added bug tag:DevOps status:Needs Triage Applied to new issues that need triage labels Jan 23, 2024
@krassowski krassowski changed the title Ensure repo fails before build when a file gets deleted ensure-repo.ts fails before build when a file gets deleted Jan 23, 2024
@JasonWeill JasonWeill removed the status:Needs Triage Applied to new issues that need triage label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants