'parallel command won't ignore config files

I have a bash script that uses bash command parallel

I find that when I run the script as a non root user, parallel still checks /root/ directory for a config file named .parallel

foo.sh

#!/bin/bash

parallel --semaphore --jobs=6 "echo hello"
parallel --semaphore --wait

Running the script as root works as expected. However running as non-root gives this error

chown bob:bob foo.sh
sudo -u bob -g bob ./foo.sh
parallel: Error: Cannot change into non-executable dir /root/.parallel: Permission denied

I've tried using the --plain flag to ignore configs

parallel --semaphore --plain

I've tried using a config pointed at /dev/null

parallel --semaphore -C /dev/null

https://docs.oracle.com/cd/E86824_01/html/E54763/parallel-1.html

How can I make parallel command not check for /root/.parallel config file?



Solution 1:[1]

What is the value of $HOME in foo.sh when running?

sudo -u bob -g bob ./foo.sh

If $HOME is not changed to /home/bob but instead remains /root then that will explain what you see.

You can add:

echo $HOME

to foo.sh to check.

Or (as @jared_mamrot says) set $PARALLEL_HOME explictly.

Why does GNU Parallel need a writeable dir?

--semaphore works by creating files in the dir.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1