Skip to content

vite-plugin-alphatab-copy: path computing issue on github pages / maybe Ubuntu in general #1577

@bali182

Description

@bali182

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm trying to deploy an app containing alphaTab on github pages, which is built using vite / alphaTab vite plugin.

On github pages the build fails while the vite-plugin-alphatab-copy plugin is trying to copy some assets into the public folder.
https://github.com/bali182/alphatab-vite-build-bug-repro/actions/runs/9906924688/job/27369512708

Messages are like this:

[vite-plugin-alphatab-copy] ENOTDIR: not a directory, copyfile '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/soundfont/LICENSE/LICENSE' -> '/home/runner/work/stick/stick/public/soundfont/LICENSE'
Error: ENOTDIR: not a directory, copyfile '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/soundfont/LICENSE/LICENSE' -> '/home/runner/work/stick/stick/public/soundfont/LICENSE'
Error: Process completed with exit code 1.

The file names are doubly present in the path its trying to copy from:
'/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/soundfont/LICENSE/LICENSE'

To see what's happening, I made a simplified version of copyAssetsPlugin.ts and when running it as an individual plugin and logging the files in copyFiles, it seems like on gh pages (maybe on Linux on general, IDK) the readdir functions file already has the full file path. So this:

await Promise.all(
  files
    .filter((f) => f.isFile())
    .map(async (file) => {
      const sourceFilename = path.join(file.path, file.name)
      console.log({
        'file.path': file.path,
        'file.name': file.name,
        sourceFilename: sourceFilename,
      })
      await fs.promises.copyFile(
        sourceFilename,
        path.join(outputPath!, subdir, file.name),
      )
    }),
)

Results in this:

{
  'file.path': '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/font/Bravura-OFL-FAQ.txt',
  'file.name': 'Bravura-OFL-FAQ.txt',
  sourceFilename: '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/font/Bravura-OFL-FAQ.txt/Bravura-OFL-FAQ.txt'
}
{
  'file.path': '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/font/Bravura-OFL.txt',
  'file.name': 'Bravura-OFL.txt',
  sourceFilename: '/home/runner/work/stick/stick/node_modules/@coderline/alphatab/dist/font/Bravura-OFL.txt/Bravura-OFL.txt'
}

And file.path has the full path of the file. So appending the file name again will result in double file names.

Expected Behavior

The build to succeed

Steps To Reproduce

Here is a simple repro to reproduce this with the latest vite and alphatab versions:
https://github.com/bali182/alphatab-vite-build-bug-repro

And here are the logs of a failed run
https://github.com/bali182/alphatab-vite-build-bug-repro/actions/runs/9906924688/job/27369512708

Link to jsFiddle, CodePen, Project

https://github.com/bali182/alphatab-vite-build-bug-repro

Found in Version

1.4 (alpha)

Platform

Web

Environment

- **OS**: ubuntu latest
- **Browser**: not relevant
- **.net Version**: not relevant

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-bundlersRelated to the bundler plugins like webpack and viteplatform-javascriptRelated to the JavaScript version of alphaTabstate-acceptedThis is a valid topic to work on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions