JAR run from terminal stops running after a couple hours - terminal

I have a Discord bot that I have only recently started running from terminal. It runs fine when running it in IntelliJ for hours or even days (yes I know waste of resources), but I have noticed that when running it in terminal now it stops after a few hours and I don't know why.
Running it with java -jar file

Problem was I was running code that looked for an external file. When running in IntelliJ it naturally ran it from the folder it existed in, but in the terminal I was running it with the full location, rather than changing directory to that folder first. So then when calling to look for X.file, it was just looking in the C drive rather than the folder it existed in.

Related

Why does running a .sh script from Visual Studio open the file instead of running it?

I am attempting to run an .sh script (which itself is supposed to kick off a series of unit tests in flask) from within Visual Studio Code running in Windows 10 and for some reason no matter what I try it only opens the file for editing instead of actually running the file.
This is the exact command I am typing:
C:\Users\my.user\MyRepo>.\scripts\run-unit-tests.sh
Here are my notes:
This is a brand new installation of Windows 10 where I believe I have enabled WSL2
I am completely unfamiliar with doing development from within Windows (coming from a Ubuntu/Linux background)
My goal is to run this script from within the built in terminal in VS Code, however I have also tried running it from a cmd prompt and also from powershell and both of those also result in opening the file in VS Code.
Addendum: more notes:
I actually have two windows machines. one is my personal machine, the other provided by my work. For whatever reason this file works fine on my personal machine but does not on my work machine. Also the bash script is in a repo which was created by others at my company so i'm certain that this can be made to run without modifying the .sh file itself.
I figured out what was going on.
In windows there are default file associations. Mine was set up to run Visual Studio Code for the .sh file extension. Also, windows does not know how to handle .sh files by default. There were likely many potential fixes for this however the one that worked was for me to re-associate the .sh file extension to open with Git Bash which I happened to also have installed on this machine.
Thanks all who tried to help.

rustc disappears when executing cargo run on windows

I am curently developing a Rust program on Windows 10. A few months ago I created a library package using cargo. Since then, I've been developing this program. Whenever I want to execute what I have, I goto to cmd and execute the following command inside my cargo folder:
cargo run --release --bin main
But, a few weeks ago something strange started to happen. Whenever I execute this same command, I notice that the program in fact starts but it finishes preemptively (I know this because of the output to the terminal). When the program finishes it is supposed to write to the terminal "FINISHED". But this never happens. If I execute the command again (without changing the code), this time the only thing that's printed to the terminal is the build message that cargo puts out. Then, when I execute a third time, I have the following message on my terminal:
error: 'cargo.exe' is not installed for the toolchain 'stable-x86_64-pc-windows-msvc'
To install, run `rustup component add cargo --toolchain stable-x86_64-pc-windows-msvc`
Then if I execute the suggested command, I have the following:
component 'cargo' for target 'x86_64-pc-windows-msvc' was automatically added because it is required for toolchain 'stable-x86_64-pc-windows-msvc'
What's weird is that if I execute the previous cargo run command on the Ubuntu terminal application that I have (it simulates a linux terminal, but I am still on my windows file system), this problem doesn't occur. I can execute 100 or 1000 times and no problems. But this isn't good, since my program creates a multi threaded environment and my Ubuntu terminal is like a virtual machine, so I don't believe that I have access to all of my laptop's memory.
Currently I have the following version of rust on windows and my ubuntu terminal:
rustup 1.18.3 (435397f48 2019-05-22)
What I have been doing until now to solve this is on my windows is to reboot my computer and reinstall rust, since when I execute "rustup self uninstall" sometimes an error of not having permissions to install it appears (I only have 1 user on my pc and supposedly I have admin privileges).
I have googled this situation, but I haven't found anything regarding rustc disappearing when executing cargo run. Now I can't even run my program on windows cmd, since this problems happens every time.
The problem was the anti virus I had on my PC.
After replacing it the program is working perfectly and finishing without the problem I had with rustc.

Meteor Vagrant: Where should the project code files be?

I have successfully configured Meteor on my Windows machine via vagrant along with running the sample app in the browser by following the tutorial given at https://gist.github.com/ahoereth/2607d2ee99103a0a9bc9.
For the last two hours, I have explored all of the Window's directories in search of the code created by meteor create sampleapp command, but I can't find any clue where the code is. As vagrant claims that code is in the Windows directory not the VM box, can anyone give me a hint where it could be hiding?
The directory that's shared with the Windows host is the /vagrant directory. In the VM, the home directory might be different, and won't be visible from Windows.
However, if you want to run the Meteor app from the shared directory, be prepared for a world of pain whenever you install a package that has a : in its name, as Windows won't support that character in the filename, and you'll get a cryptic error in the VM.
Since packages in Meteor 0.9+ regularly have : in their names, developing Meteor apps in the VM/Windows shared directory is a no-go.

Using Launchd with Mavericks and Ruby

Upgraded to Mavericks and now launchd / Lingon is unable to launch Ruby scripts. I have the files set to be executable (using chmod +x), and have the first lines set to
#!/usr/bin/ruby
However, I keep getting the following error in Console:
com.apple.launchd.peruser.501[169] (craig.logging[754]): Exited with code: 1
That is a permissions error, but I have no idea what permissions to fix or change. The script runs fine in terminal with ruby.
This is driving me nuts.
Update: the Ruby scripts that are causing the problem write their output to another file, for example, in my Dropbox. But I'm running the launchd files as myself who has admin privileges to write to those files. No idea what's going wrong...]
Update 2: Have started using Applescript to launch the Terminal and run my scripts, but this is pretty clumsy and inelegant. Anyone else have any insight to why launchd won't run scripts that write their output to files? Or is anyone having success with scripts that do?
Update 3: The failures were being triggered because of encoding issues. I had to specifically set file.open(path/to/file, encoding: 'UTF-8') for the scripts to work.
Thanks everyone.
I had this same problem on a Mavericks box with several Ruby scripts I have set to run at various intervals. I found that while this machine that had the OS upgraded was failing, my new MacBook Pro that shipped with Mavericks could schedule the same scripts off launchd just fine. I ended up erasing the machine and reinstalling Mavericks (and everything else) from scratch, and then scheduling the scripts began to work.
Not the most delicate answer, I know, but Worked For Me™.
I'm still not entirely sure why, but the permissions errors were being triggered because of encoding issues. I had to specifically do this:
File.open(path/to/file, encoding: 'UTF-8')
for the scripts to work.
Thanks everyone for your help.

Mac OS install application and run a script on startup

I'm looking for a way to package my application with the added requirement that I need to add a python script to always run on startup.
What I've been trying so far is having a .pkg that installs the .app into the applications folder and adds the python script (wrapped in a .plist launch daemon) to the user's LaunchAgents folder.
I've tried a lot of different things, but for whatever reason the python script runs fine on the command line and just doesn't work when running through launchctrl. I could go into what the problems were, but I feel that would make more sense as a separate question.
I am wondering if I should be using a different approach to achieve my goal of installing the app in Applications and having a python script run on boot. Is there a more standard solution that I am missing perhaps? Thanks.

Resources