Rocket U2 | UniVerse & UniData

 View Only

 Different PATH when using uopy

Héctor Cortiguera's profile image
PARTNER Héctor Cortiguera posted 09-05-2024 09:24

Hi all

I have some problems when connecting to servers using uopy, as the PATH variable is wrong.

From the terminal console:

>SH -c "echo $PATH"
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/uv/bin
>SH -c "uv -version"
UniVerse 14.1.0

When using uopy:

cmd = uopy.Command()
suffix = "\r\n"
cmd.command_text = 'SH -c "echo $PATH"'
cmd.run()
print(f'{cmd.command_text} = {cmd.response.removesuffix(suffix)}')
cmd.command_text = 'SH -c "uv -version"'
cmd.run()
print(f'{cmd.command_text} = {cmd.response.removesuffix(suffix)}')

The output is:

SH -c "echo $PATH" = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SH -c "uv -version" = SH: line 1: uv: command not found

What's the issue with the uopy connection having an incomplete PATH value?

John Jenkins's profile image
John Jenkins

Hector,

Please check the default system-wide PATH - on Linux this is probably in /etc/environment, though bash will default if it is not set to /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:. - and I suspect this is no coincidence.

On the surface, it looks like you are probably picking up the default bash profile which is hard coded in bash. and not inheriting the environment variables of the specific user session.  

Please verify, and try adding the needed environment variable(s) to /etc/environment and let us know if this works for you or if the issue is different to that ssupected.

Added: Just on the off-chance, make sure the environment variables are exported in the parent shell.

Regards

JJ

Steve Wingfield's profile image
ROCKETEER Steve Wingfield

Hi Hector,

This doesn't answer your exact question, but...  another way to access the UV release level is via 

CT VOC RELLEVEL

This can be done via a UOPY command that doesn't require shelling out (and so avoids the "command not found" problem you encounter in the new shell)

>CT VOC RELLEVEL
 
     RELLEVEL
0001 X
0002 11.4.1
0003 NEWACC
0004
0005 11.4.1
Mike Rajkowski's profile image
ROCKETEER Mike Rajkowski

Hector,

UniObjects does not check or use the personal profile information of the user who is connecting.  It is based on the environment variables of the session that started the unirpcd daemon. 

You can either restart the daemon with the desired environment variables, or set the environment variables after making the uo connection.