question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: EPERM: operation not permitted

See original GitHub issue
  • Version: 22.9.1
  • Electron Version: 9.3.2
  • Electron Type (current, beta, nightly): Current

Electron updater: 4.3.5

  • Target: Windows, nsis

Hello, I’ve been trying to make the autoUpdate work for days for my electron desktop app and I keep having the same error. The upload publishes well in the github private repository but when I try to download it I always get this error: Error: EPERM: operation not permitted, open ‘C:\Users\usuario\AppData\Local\privatenameexample\pending\temp-privatename-Setup-1.0.1.exe’

This is the command I use to publish it: electron-builder build --win --publish always

My package.json:

{ "name":` "example",
  "version": "1.0.0",
  "main": "main.js",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "electron-builder build --win --publish never",
    "deploy": "electron-builder build --win --publish always",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "start:electron": "ng build --base-href ./ && electron .",
    "electron-package-win": "ng build --prod && electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --ignore=/src --overwrite"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.2",
    "@angular/common": "~10.0.2",
    "@angular/compiler": "~10.0.2",
    "@angular/core": "~10.0.2",
    "@angular/forms": "~10.0.2",
    "@angular/localize": "~10.0.2",
    "@angular/platform-browser": "~10.0.2",
    "@angular/platform-browser-dynamic": "~10.0.2",
    "@angular/router": "~10.0.2",
    "@fortawesome/angular-fontawesome": "^0.7.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.28",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@ng-bootstrap/ng-bootstrap": "^7.0.0",
    "bootstrap": "^4.5.0",
    "chart.js": "^2.9.3",
    "electron-log": "^4.3.0",
    "electron-pos-printer": "^1.2.4",
    "electron-updater": "^4.3.5",
    "ng-connection-service": "^1.0.4",
    "ng2-charts": "^2.4.1",
    "ngx-electron": "^2.2.0",
    "ngx-image-compress": "^8.0.4",
    "resize-base64": "git+https://github.com/hendrik-scholz/resize-base64.git#master",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "update-electron-app": "^2.0.1",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.1",
    "@angular/cli": "~10.0.1",
    "@angular/compiler-cli": "~10.0.2",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0-next.1",
    "electron": "^9.3.2",
    "electron-builder": "^22.8.1",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/exampleuser/example"
  }
}

My electron-builder.json

{
    "productName": "example",
    "appId": "id.example.example",
    "directories": {
    "output": "release/${version}"
    },"files": [
        "**/*",  
        "!**/*.ts",  
        "!*.code-workspace",  
        "!LICENSE.md",  
        "!package.json",  
        "!package-lock.json",  
        "!src/",  
        "!e2e/",  
        "!hooks/",  
        "!angular.json",  
        "!_config.yml",  
        "!karma.conf.js",  
        "!tsconfig.json",  
        "!tslint.json"  
    ],  
    "win": {  
        "target": [  
          "nsis"  
        ]  
      },
    "nsis":{
      "oneClick": false,
      "allowToChangeInstallationDirectory":true,
      "perMachine": true
      },
    "publish": [
    {
    "provider": "github",
    "repo": "example",
    "owner": "exampleuser",
    "vPrefixedTagName": true,
    "token": "xxx",
    "private": true,
    "releaseType": "release",
    "publishAutoUpdate": true
    }
    ]
}

My main.js where I call it.

const {app, BrowserWindow,ipcMain} = require('electron')
const { autoUpdater } = require('electron-updater');
var log = require('electron-log');
log.transports.file.level = 'info';
log.transports.file.file = __dirname + 'log.log';
autoUpdater.autoDownload = false;

const url = require("url");
const path = require("path");
const {PosPrinter} = require("electron-pos-printer");

let mainWindow
function createWindow () {
  mainWindow = new BrowserWindow({
    //fullscreen:true,
    height: 600,
    width: 800,
    //frame:false,
    webPreferences: {
      nodeIntegration: true
    }
  })
  mainWindow.setMenuBarVisibility(false)
  //ON OPEN SET FULL SCREEN
  // mainWindow.setFullScreen(true)

  mainWindow.loadURL(
    url.format({
      pathname: path.join(__dirname, `/dist/index.html`),
      protocol: "file:",
      slashes: true
    })
  );
  // Open the DevTools.
  mainWindow.webContents.openDevTools()

  mainWindow.on('closed', function () {
    mainWindow = null
  })
 
  mainWindow.once('ready-to-show', () => {
  });
  setInterval(function(){ 
    autoUpdater.checkForUpdatesAndNotify(); 
    log.error('-- Looking for updates -- 20s cooldown --')
  }, 20000);
}
//FIN CREATE WINDOW
app.on('ready', createWindow)

app.on('window-all-closed', function () {
  log.error("Closing app");
  app.quit();
})

app.on('activate', function () {
  if (mainWindow === null) createWindow()
})

ipcMain.on('app_version', (event) => {
  event.sender.send('app_version', { version: app.getVersion() });
});

function closeWindow(){
  console.log("Closing window")
  mainWindow.close();
}
ipcMain.on('closeWindow', (event, arg) => {
  closeWindow()
})
autoUpdater.on('update-available', () => {
  // mainWindow.webContents.send('update_available');
  log.error('Update available')
  autoUpdater.autoDownload = true;
});
autoUpdater.on('update-downloaded', () => {
  // mainWindow.webContents.send('update_downloaded');
  log.error('Downloaded')
});
autoUpdater.on('checking-for-update', () => {
  log.error('Checking for update')
})
autoUpdater.on('update-not-available', (ev, info) => {
  log.error('Checking ... update not available')
})
autoUpdater.on('download-progress', (ev, progressObj) => {
  log.error('Download progress')
  // let log_message = "Download speed: " + progressObj.bytesPerSecond;
  // log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
  // log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
  // log.error(log_message)

  // sendStatusToWindow(log_message);
  // Commented because it says undefined
})

ipcMain.on('restart_app', () => {
  autoUpdater.quitAndInstall();
});

autoUpdater.on('error', message => {
  log.error('There was a problem updating the application')
  log.error(message)
})

This is where the error tells me to go and this is what I get when clicking manually: image

And this is the logs I get, it detects that there is an update, and starts downloading it but it gets like corrupted image

I have tried everything, trying to download it in a public respository, verifyUpdateCodeSignature: false because maybe its my antivirus that blocks it but I have disable it, but the error is always the same. I haven’t done the app quit and install part because I want it to download well first which I can’t succeed. Thank you very much!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

4reactions
GODAsderelcommented, Nov 9, 2020

Solved

0reactions
BozaGajiccommented, Nov 24, 2022

@GODAsderel Can you please share your solution? I encountered the same issue. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm - EPERM: operation not permitted on Windows
My Solution for the problem · Right-click on the project folder · Go to properties -> Security Tab · Select Users -> Edit...
Read more >
npm ERR! Error: EPERM: operation not permitted [Solved]
To solve the error npm ERR! Error: EPERM: operation not permitted, close your IDE (e.g. Visual Studio Code) and stop your development server....
Read more >
Error: EPERM: operation not permit… | Apple Developer Forums
I am installing packages for NODEJS/NPM and am receiving the following error, which, apparently, is not an error with the software, but with...
Read more >
Error: EPERM: operation not permitted, mkdir 'C:\Users ...
I was facing the same problem for 3 days and got this solution for it... It's because of old files lying in your...
Read more >
How To Fix npm Error Eperm Operation Not Permitted Mkdir ...
Hello Guys!In this tutorial ,I provided the complete solution of React JS FrameworkError :npm - EPERM : operation not permitted on ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found