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

"portable" it's not so portable #1612

Closed
distributev opened this issue Jun 2, 2017 · 9 comments · May be fixed by qcif/data-curator#563
Closed

"portable" it's not so portable #1612

distributev opened this issue Jun 2, 2017 · 9 comments · May be fixed by qcif/data-curator#563

Comments

@distributev
Copy link

  • Version: "electron-builder": "^14.5.2",
  • Target: build -w --ia32

"win": { "target": [ "portable" ] }

I am not sure what I am doing wrong. I thought "portable" it's exactly the targeting I need however it does not work as expected.

In development I have an env_development.json with relative folder paths which works great.

{ "name": "development", "folders": { "config": "./playground/config", "logs": "./playground/logs", "temp": "./playground/temp" } }

In "production" (that is the portable .exe file which is generated by nsis) the equivalent env_production.json is

{ "name": "production", "folders": { "config": "./config", "logs": "./logs", "temp": "./temp" } }

In production (when I run the .exe file) the relative paths are not correctly resolved.

Further more, If I log.info (__dirname), I get each time (each different execution) a different randomly generated temp path like

C:\Users\username\AppData\Local\Temp\nsh2EC4.tmp\app\resources\app.asar\app

I think this is happening because of how asar packaging works however the result is that "portable" is not actually portable.

One workaround would be to read the configuration files from the userDataPath location - however I am trying to keep the configuration files next to the generated exe file since this is more easily findable / accessible to the user.

I think "portable" it's not really portable because __dirname it's not reliable and it has a different (random) value each time when I execute the generated .exe file.

What I am doing wrong?

@black-snow
Copy link
Contributor

Have you tried using the latest version of electron-builder?

@distributev
Copy link
Author

Just tried now with the latest version of electron-builder. It's doing the same.

@develar
Copy link
Member

develar commented Jun 6, 2017

Do you expect that your config will be in the same dir as exe?

@distributev
Copy link
Author

Yes you are correct.

Currently if I "copy-paste" the exe folder from one computer to another the software will break since the configuration files will not be available.

This will enable to run the software from an USB stick since everything will be "self sufficient / contained" inside the folder where the exe is located.

develar added a commit to develar/electron-builder that referenced this issue Jun 12, 2017
@develar
Copy link
Member

develar commented Jun 12, 2017

electron-builder 19.0.0 will set env PORTABLE_EXECUTABLE_DIR. You can use it to store config inside the folder where the exe is located.

@distributev
Copy link
Author

I think this will work. Thank you.

I see that v19.0.0 is currently tagged as "pre-release" - When this version will be tagged as "stable" so that will become available on npm to use. Currently npm shows as the latest version as 18.6.2

https://www.npmjs.com/package/electron-builder

Can I load v19.0.0 from npm before it is tagged as "stable"?

@black-snow
Copy link
Contributor

@distributev yes, just npm i --save-dev [email protected]

@vanowm
Copy link

vanowm commented Dec 4, 2021

Any example how to use this APP_EXECUTABLE_DIR ?

@harimayco
Copy link

Any example how to use this APP_EXECUTABLE_DIR ?

replace __dirname with process.env.PORTABLE_EXECUTABLE_DIR in your code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants