Linux Environment Variables

Everything else that doesn't fall into one of the other PB categories.
swhite
Enthusiast
Enthusiast
Posts: 783
Joined: Thu May 21, 2009 6:56 pm

Linux Environment Variables

Post 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
Simon White
dCipher Computing
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux Environment Variables

Post 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.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18150
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Linux Environment Variables

Post by Fred »

I didn't tried yet, but did you check the second answer here ?

https://stackoverflow.com/questions/164 ... nux-system
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux Environment Variables

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
swhite
Enthusiast
Enthusiast
Posts: 783
Joined: Thu May 21, 2009 6:56 pm

Re: Linux Environment Variables

Post 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.
Simon White
dCipher Computing
Fred
Administrator
Administrator
Posts: 18150
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Linux Environment Variables

Post by Fred »

you will probably need to restart the deamon
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Linux Environment Variables

Post 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.
bye,
Daniel
Post Reply