Page 1 of 1

Linux Environment Variables

Posted: Wed Mar 05, 2025 6:57 pm
by swhite
Hi

The newer versions of Purebasic for Linux requires the PUREBASIC_HOME variable to be set. I am not a Linux guru and I am not sure how to make this permanent so that it is available when I login or when a daemon runs etc. I have third party tool that will compile Purebasic on the fly when it detects a change. It works perfectly with PB 5.73 and compiles the changed files. However, it does not compile the file with PB 6.20. The PB 6.20 compilers all work and I have tested the standby features and they work. So I am wondering if the environment variable is missing when the daemon runs under another user. Therefore I am wondering how this should be configured so it is available to everyone and everything that runs on the server.

Thanks,
Simon

Re: Linux Environment Variables

Posted: Thu Mar 06, 2025 12:27 am
by mk-soft
I have never used the PUREBASIC_HOME variable before.
So far I have always opened and started or compiled the files directly from the IDE.
An exception is when I start the pbcompiler from the terminal.
There I have started a bash script before to have all necessary settings and to use different compilers.

Re: Linux Environment Variables

Posted: Thu Mar 06, 2025 10:31 am
by Fred
I didn't tried yet, but did you check the second answer here ?

https://stackoverflow.com/questions/164 ... nux-system

Re: Linux Environment Variables

Posted: Thu Mar 06, 2025 11:18 am
by mk-soft
I don't use the global environment setting because I use different PB versions on Linux.

If I need the pbcompiler in the terminal, I start a new bash in this script.
Thus, the environment settings are only valid for the running bash.

Don't forget to set the permission as program
pb.sh [path_to_purebasic_home]

Code: Select all

#!/bin/bash

# Test mandatory PureBasic path parameter
if [ -z "$1" ]; then
	echo "Invalid parameters: Missing argument for target PureBasic directory"
	exit 1
fi


# Set PUREBASIC_HOME and ensure compiler and IDE are in the PATH
export PUREBASIC_HOME=$1
export PATH="$PUREBASIC_HOME/compilers:$PUREBASIC_HOME:$PATH"

# Test if the PureBasic home is valid
if [ -f "$PUREBASIC_HOME/compilers/pbcompiler" ]; then
	echo "Start terminal for pbcompiler"
	#purebasic
	bash
else
	echo "Invalid path for target PureBasic directory"
	exit 1
fi

Re: Linux Environment Variables

Posted: Fri Mar 07, 2025 3:39 pm
by swhite
Fred wrote: Thu Mar 06, 2025 10:31 am I didn't tried yet, but did you check the second answer here ?

https://stackoverflow.com/questions/164 ... nux-system
No I have not tried it yet. I did add the PUREBASIC_HOME variable to the /etc/environment file and that seems to work for when I log in. I do not know yet whether that helps with daemons etc.

Re: Linux Environment Variables

Posted: Fri Mar 07, 2025 3:58 pm
by Fred
you will probably need to restart the deamon

Re: Linux Environment Variables

Posted: Sat Mar 08, 2025 5:44 am
by DarkDragon
Permanently setting environment variables:


For systemd daemons/services

https://serverfault.com/a/413408


For init.d you have a starter script reacting to start/stop commands usually which can be edited.


For login shells use .bashrc/.profile/... as usual.