I'm working with Ubuntu 18.04 and making builds using electron-builder (node.js, react application). Finally I have workable building which makes some zips (win and linux) and deb (linux). When I install the deb, it works well, but when I unzip the builds, I can't run them:
windows version doesn't work via wine
linux version is not executable.
I'm using Ubuntu 18.04, electron 4.0.4, electron-builder 20.38.5.
Here is my package.json
"scripts": {
"dist": "electron-builder --linux --windows",
"postinstall": "electron-builder install-app-deps"
},
"build": {
"appId": "my_app_id",
"extraFiles": [
"assets"
],
"win": {
"target": "zip",
"icon": "assets/icon.png"
},
"linux": {
"target": [
"deb",
"zip"
],
"icon": "assets/icon.icns"
}
}
So, first I run npx webpack to build the app. Then I run npm run dist to make the builds. It creates linux-x64.zip, win32-x64.zip, amd64.deb. But the thing inside the zips doesn't work.
One important note: I got this stuff as a heritage from other developer, and maybe he didn't commit something necessary and maybe all of this staff was just his training solution and doesn't work at all.
Seems like the problem has gone. I don't need the linux zip, deb works fine. And windows zip works well (tested via VirtualBox).
Related
electronic app has the following package.json:
package.json
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
}
I can read environment variables by running the electron app with npm start.
process.env.JAVA_HOME
the result exists.
However, if I create a distribution of the electronic app with the npm run dist command and then run the distribution app, I cannot read the environment variable.
the result is undefined
How can I read environment variables in distribution of the electronic app?
I'm working on macOS Monterey
I have the following scripts in my electron js app's package.json
"start": "electron .",
"dev": "nodemon --exec electron ."
butI get the following error when I run the app as npm run dev
'electron' is not recognized as an internal or external command, operable program or batch file
and the app crashes. However, when I run it as npm start it runs fine with no issues.
What maybe the issue with nodemon?
You can resolve it by executing electron with npx:
"dev": "nodemon --exec npx electron ."
but this will run a new instance every time you make a change.
Alternatively, you can install electron globally:
npm i -g electron
I'm trying to build an executable file for windows from my linux but so far I have not been able to do it.
According to the documentation, it tells me that here I could configure, for example, the output folder.
pluginOptions: {
electronBuilder: {
outputDir: 'desktop-for-windows',
},
},
and if it works but does not say anything about how to change the platform (s.o) to build.
also try testing the following command:
npm run electron:build --win
but by default it builds for linux
Ran into same thing trying to move from an older boiler plate to using Vue-CLI 3 just now.
Run this from within the project directory and see if it works:
./node_modules/.bin/vue-cli-service electron:build --windows
I got the --windows from the ui.js file in the vue-cli-plugin-electron-builder directory under node_modules. Other options are --linux and --macos. I'm surprised I don't see a --all flag or that all isn't the default.
If you add "build:win": "vue-cli-service electron:build --windows" under scripts in your package.json then you can instead run npm run build:win from there on.
I just faced the same problem and found pretty easy answer.
You can just run npm run electron:build -- --linux deb --win nsis in the project directory.
There is more about it here: https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/recipes.html#multi-platform-build
How can you launch Ruby on Rails using the built-in Visual Studio Code Launch/Debug features?
How do you fix the Debugger terminal error: Process failed: spawn rdebug-ide ENOENT error?
Setup and Launch
Install the VS Code Ruby plugin (hit ⌘+⇧+P on macOS or ctrl+⇧+P elsewhere and type ext install in the prompt, then search for ruby)
Install some required Ruby gems
gem install ruby-debug-ide
gem install debase
Add a launch configuration in Visual Studio Code (example configuration shown below)
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"env": {
"PATH": "YOUR_PATH_HERE",
"GEM_HOME": "YOUR_GEM_HOME_HERE",
"GEM_PATH": "YOUR_GEM_PATH_HERE",
"RUBY_VERSION": "YOUR_RUBY_VERSION_HERE"
},
"args": [
"server"
]
}
In some cases you might not need to specify the env section.
In other cases you can launch VS Code using the CLI (i.e. from the terminal), which on some systems automatically sets the correct environment variables.
Run!
Troubleshooting
If you get the following error
Debugger terminal error: Process failed: spawn rdebug-ide ENOENT
Your environment variables (env) are most likely not set and the plugin cannot find the necessary binaries.
Make sure all gems are installed and try running bundler install --binstubs if you use bundler.
Make sure the env section is set in your launch configuration. Run the following shell command to generate your env:
printf "\n\"env\": {\n \"PATH\": \"$PATH\",\n \"GEM_HOME\": \"$GEM_HOME\",\n \"GEM_PATH\": \"$GEM_PATH\",\n \"RUBY_VERSION\": \"$RUBY_VERSION\"\n}\n\n"
Windows
Make sure to use the correct spelling (and capitalization) of the path variable, i.e. Path on Windows
Sources:
https://github.com/rubyide/vscode-ruby/issues/214#issuecomment-393111908
https://www.reddit.com/r/vscode/comments/5w1acs/getting_error_debugger_terminal_error_process/
How to extend $PATH in launch.json in Visual Studio Code?
I spent most of a day trying to solve this.
I ended up stripping my launch.json config down to the following:
"configurations": [
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "/Users/mitch/.rvm/gems/ruby-2.3.0#gg_portal/bin/rails",
"args": [
"server"
],
"useBundler": true,
"pathToRDebugIDE": "/Users/mitch/.rvm/gems/ruby-2.3.0#gg_portal/gems/ruby-debug-ide-0.6.1",
"pathToBundler": "/Users/mitch/.rvm/gems/ruby-2.3.0#gg_portal/wrappers/bundle",
"showDebuggerOutput": true
}
]
Firstly, especially if you're using RVM & have different Gemsets, make sure your paths are consistent with the correct Gemset.
What solved the problem for me was pathToBundler.
which bundle
/Users/mitch/.rvm/gems/ruby-2.3.0#gg_portal/bin/bundle
There looks to be some incompatibility around setting the path to the binstubs bundler (shown above) and the bundler pointed to from /wrappers/ (shown below), so changing pathToBundler to:
"pathToBundler": "/Users/mitch/.rvm/gems/ruby-2.3.0#gg_portal/wrappers/bundle",
solved the problem.
There is a kind of related discussion here:
https://github.com/rails/rails/issues/31193
which talks about binstubs though not specifically VSCode & debugging.
If you're using a ruby version manager such as rbenv that relies on bash shims, try launching VS Code from the terminal. This should allow VS Code to pick up on the env variables that rbenv sets. Alternatively you can set your env vars in launch.json, but this is not a very maintainable solution.
I have an Electron app that compiles fine on Windows using npm run ewin:
"scripts": {
"start": "electron main.js",
"pack": "build",
"ewin": "build --win --ia32 --x64",
"ewinsign": "export CSC_LINK=file:///${HOME}/certificates/certificate.pfx; export CSC_KEY_PASSWORD=\"$( cat ${HOME}/certificates/certificates_pw.txt )\"; npm run clean:win && build --win --ia32 --x64",
},
So I added the ewinsign in an attempt to get it to sign the app.
I based ewinsign on this discussion:
https://discuss.atom.io/t/signing-windows-app-installer/32511
ewinsign fails with this error:
'export' is not recognized as an internal or external command,
operable program or batch file.
I did not really expect it to work because I am running my build on Windows, and bash commands are not typically available on Windows.
Signing Windows apps should be something with a well known solution so I am hesitant to start hacking together my own solution.
In summary:
I am building my app on Windows.
I have my certificate located here: ${HOME}/certificates/certificate.pfx
I have a file with the password located here: ${HOME}/certificates/certificate_pw.txt
I can successfully build unsigned with npm run ewin.
How can I add a ewinsign command that will build a signed Windows app?
I ended up writing a bat script wrapper that sets the environment variables. That was easier to debug because I could add env statement to see what the environment variables were set to.
Here is the script:
set CSC_LINK=file://%USERPROFILE%/certificates/certificate.pfx
set /p CSC_KEY_PASSWORD=<"%USERPROFILE%/certificates/certificates_pw.txt"
npm run ewin
Of particular note is the =< batch syntax to read a file into a variable. and the /p syntax to only read one line.
If you wanted to use that command and try with the windows replacements, you would be looking for the following:
set is the command that you would use to create a windows
environment variable (instead of export)
type is the equivalent of the bash 'cat' for
windows.
What is {HOME} for you? Is that in your "C:\Users\"Your
User Name" directory? If so, you could use
%USERPROFILE% to get that value.
The resulting code would look something like this:
"ewinsign": "set CSC_LINK=file:///%USERPROFILE%/certificates/certificate.pfx; set CSC_KEY_PASSWORD=\"$( type %USERPROFILE%/certificates/certificates_pw.txt )\"; npm run clean:win && build --win --ia32 --x64"
However, I haven't tested that code, so I am not sure if it will work or not.
Now, I haven't code signed with electron-builder, but I would assume that you would use the windows build options to enforce a certificate. This would be setup in the "build" section of your package.json file:
"build":{
"appid":"yourid",
"asar": true,
"forceCodeSigning": true,
"win":{
"target": "...",
"publisherName": "..."
"certificateFile": "...",
"certificatePassword":"...",
"certificateSubjectName":"...",
"certificateSha1":"...",
"signingHashAlgorithms":"..."
}
}
You might have to play around with those values to get something working, but based on the documentation, that is how I would do it. Reference the parent options here