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

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

Closed
1 task done
bali182 opened this issue Jul 12, 2024 · 5 comments · Fixed by #1579
Closed
1 task done
Assignees
Labels
area-bundlers Related to the bundler plugins like webpack and vite platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on. type-bug 🕷️

Comments

@bali182
Copy link

bali182 commented Jul 12, 2024

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

@bali182 bali182 added the state-needs-triage Bug not triaged yet. label Jul 12, 2024
@bali182 bali182 changed the title vite-plugin-alphatab-copy: path computing issue on github pages vite-plugin-alphatab-copy: path computing issue on github pages / maybe Ubuntu in general Jul 12, 2024
@Danielku15 Danielku15 added type-bug 🕷️ state-accepted This is a valid topic to work on. platform-javascript Related to the JavaScript version of alphaTab area-bundlers Related to the bundler plugins like webpack and vite and removed state-needs-triage Bug not triaged yet. labels Jul 13, 2024
@Danielku15
Copy link
Member

Thanks for the detailed analysis. That's indeed a strange behavior. Seems fs.path was deprecated in Node 20.12 in favor of parentPath. See:

nodejs/node#50838
nodejs/node#50976

@bali182
Copy link
Author

bali182 commented Jul 14, 2024

Just to confirm, builds prefectly with vite in 1.4.0-alpha.1085, thank you for the quick fix!

@juliandevnguitar
Copy link

Hi, i´ve been struggling with the same error trying to deploy on netlify and vercel. Im using next js, and deployed once with success, then i started working on some minor updates to my app (almost style and ui work, so nothing essential changed with alphatab) then when i did the new commit. I encounter the same issue on the deployment log:

1:57:44 PM: Creating an optimized production build ...
1:57:51 PM: unhandledRejection [Error: ENOTDIR: not a directory, copyfile 'node_modules/@coderline/alphatab/dist/font/Bravura-FONTLOG.txt/Bravura-FONTLOG.txt' -> 'public/alphatab/font/Bravura-FONTLOG.txt']

so i think im dealing with the same problem mentioned above. Maybe i could upgrade to 1.4.0 and give it a try? Is there a public version or i have to sign up to a wish list or something? Thank for your time

@Danielku15
Copy link
Member

The 1.4.0 prerelease versions are also available via NPM: https://www.npmjs.com/package/@coderline/alphatab?activeTab=versions

@juliandevnguitar
Copy link

Thank you for the quick response as always. Just to update, upgrading the netlify config so that the docker cointainer installs the latest node version worked perfectly, i didnt upgrade alphatab, but the deployment was successfull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bundlers Related to the bundler plugins like webpack and vite platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on. type-bug 🕷️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants