electron / windows-installer

Build Windows Installers for Electron apps
MIT License
1.58k stars 261 forks source link

electron-winstaller only gives the error "the path specified, the file name or both are too long." #219

Open xDeltaFox opened 6 years ago

xDeltaFox commented 6 years ago

When creating the installer, it always gives the same error:

C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp>npm run setup

> infinityapp@0.0.25 setup C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp
> node build.js --force

creating windows installer
Error: Failed with exit code: 1
Output:
Tentando construir o pacote de 'infinityapp.nuspec'.
O caminho especificado, o nome do arquivo ou ambos sao muito longos. O nome de arquivo totalmente qualificado deve ter menos de 260 caracteres e o nome do diret�rio menos de 248 caracteres.

    at ChildProcess.proc.on.code (C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp\node_modules\electron-winstaller\lib\spawn-promise.js:62:16)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! infinityapp@0.0.25 setup: `node build.js --force`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the infinityapp@0.0.25 setup script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xDeltaFox\AppData\Roaming\npm-cache\_logs\2017-12-24T13_22_37_506Z-debug.log

I do not know what to do anymore, can anyone help me?

jegj commented 6 years ago

Any news about this issue?

alexanderturinske commented 6 years ago

The error message says it all: Trying to build the 'infinityapp.nuspec' package. The specified path, the file name, or both are too long. The fully qualified file name must be less than 260 characters and the directory name less than 248 characters. The project is nested in too many folders, making the file path length exceed the limit of allowed characters, which is 260. This was a limitation with Windows, but was removed in Windows 10, but you had to enable the removal of this limit (https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows).

Solution Move your project folder closer to the root directory so that the absolute path to your project does not exceed 260 characters

EDIT: Also ensure where you are attempting to save your output does not exceed the character limit.

SujitSingh commented 6 years ago

@alexanderturinske I am also seeing this issue today. And my deepest project path goes max to 65 characters.

jegj commented 6 years ago

@SujitSingh move the project to the root folder works for me, also i found another solution if you are using electron-packager just set the flag --asar

alexanderturinske commented 6 years ago

@SujitSingh Also ensure the output path does not exceed the max amount of characters. Can you post your error, the options you are using, the file path to your folder, and the expected file path of your output?

SujitSingh commented 6 years ago

@jegj yes, you are correct. Installer from an asar format file works perfectly(in my other project). But in my case, I am running a local server inside the app 😆. So, I need the folder structure to serve static files.

@alexanderturinske, below are options which I am using -

const rootPath = path.join('./');   // C:\Demo_Tool\   <-- Root path
const outPath = path.join(rootPath, 'widget_builds');

const settings = {
  appDirectory: path.join(outPath, 'demo-tool-win32'),  // also tried names with underscore(_) and without hyphen(-).
  outputDirectory: path.join(outPath, 'windows-installer'), // C:\Demo_Tool\widget_builds\windows-installer
  noMsi: true,
  authors: 'Sujit',
  exe: 'demo-tool.exe',
};

After approximately 15-20 mins, the command generates following errors.

> demo-tool@0.2.0 create-installer-win C:\Demo_Tool
> node src/createInstaller.js

Well, sometimes you are not so lucky: Failed with exit code: 4294967295
Output:
System.AggregateException: One or more errors occurred. ---> System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.InternalGetDirectoryName(String path)
   at Squirrel.ReleasePackage.<>c__DisplayClass14_0.<extractZipWithEscaping>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Squirrel.ReleasePackage.CreateReleasePackage(String outputFile, String packagesRootDir, Func`2 releaseNotesProcessor, Action`1 contentsPostProcessHook)
   at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String setupIcon, Boolean generateMsi, String frameworkVersion, Boolean generateDeltas)
   at Squirrel.Update.Program.executeCommandLine(String[] args)
   at Squirrel.Update.Program.main(String[] args)
   at Squirrel.Update.Program.Main(String[] args)
---> (Inner Exception #0) System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.InternalGetDirectoryName(String path)
   at Squirrel.ReleasePackage.<>c__DisplayClass14_0.<extractZipWithEscaping>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---
Arytecs commented 5 years ago

@jegj I used --asar=true but I'm still having this problem. There is anything else I need to know?

jegj commented 5 years ago

@Arytecs did you try to move the project to the root folder ?? also i don't think this makes a difference but i used the flag as --asar instead of --asar=true

Arytecs commented 5 years ago

Yes I tried this too...

jegj commented 5 years ago

Maybe you should update npm, delete the node_modules dir and try again

JenRobertson commented 4 years ago

I fixed this by adding the following line to my package.json:

  "config": {
    "forge": {
      "packagerConfig": {
        "asar": true
      },
john-okeefe commented 3 years ago

@JenRobertson On your advice I added asar and it caused Packaging Application to run for over an hour doing nothing.

cyraid commented 3 years ago

I have expanded paths enabled in my registry.. Is there an option to force disable this check?

MariaCobretti commented 3 years ago

did anyone manage to do it without setting asar to true?

Franco8888 commented 1 year ago

I fixed this by adding the following line to my package.json:

  "config": {
    "forge": {
      "packagerConfig": {
        "asar": true
      },

Where in package.json do I add this?

chriszrc commented 1 year ago

The error message says it all: Trying to build the 'infinityapp.nuspec' package. The specified path, the file name, or both are too long. The fully qualified file name must be less than 260 characters and the directory name less than 248 characters. The project is nested in too many folders, making the file path length exceed the limit of allowed characters, which is 260. This was a limitation with Windows, but was removed in Windows 10, but you had to enable the removal of this limit (https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows).

Solution Move your project folder closer to the root directory so that the absolute path to your project does not exceed 260 characters

EDIT: Also ensure where you are attempting to save your output does not exceed the character limit.

I've enabled removing the limit via the registry, but still get the error when building. Is there somewhere to declare "longPathAware" value?

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell

Moving my application to /c/myapp rather than the typical /c/Users/User/Github/myapp did work as a workaround-

chriszrc commented 1 year ago

I fixed this by adding the following line to my package.json:

  "config": {
    "forge": {
      "packagerConfig": {
        "asar": true
      },

Where in package.json do I add this?

you can add that just to the regular root level of the package.json

Adermi commented 1 year ago

我也碰到这个问题了,用npm ls查看下有没有异常的第三方包,我用npm ls查看之后发现列表里有个跟我项目一样的npm包,用npm uninstall卸载了就没这个问题了