# PATH issue when using mender-connect

**URL:** <https://hub.mender.io/t/path-issue-when-using-mender-connect/3301>\
**Category:** General Discussions\
**Created:** [March 4, 2021, 6:06pm UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301 "2021-03-04T18:06:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hacpa](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@hacpa](https://hub.mender.io/u/hacpa)\
**Post date:** [March 4, 2021, 6:06pm UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/1 "2021-03-04T18:06:26Z")

</div>

As I mentioned in this other thread: [Using update module as a rootfs-image](https://hub.mender.io/t/using-update-module-as-a-rootfs-image/3288)  
I am currently experimenting with Mender 2.6 and noticed a strange PATH issue while using the shell provided by mender-connect. This is with Yocto, meta-mender branch dunfell.

When I run some Mender CLI commands through the remote shell, I get errors such as these:

```auto
root@osu-00e0709d97ea:~# mender show-artifact
ERRO[0000] Failed to read the current active partition: exec: "mount": executable file not found in $PATH 
dev-setup-offline-1.0.13
root@osu-00e0709d97ea:~# mender send-inventory
ERRO[0000] failed to force updateCheck: getMenderDaemonPID: Failed to run systemctl 
root@osu-00e0709d97ea:~#

```

But I can launch “mount” and “systemctl” manually in the same shell:

```auto
root@osu-00e0709d97ea:~# mount  
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
[...]
root@osu-00e0709d97ea:~# systemctl --help
systemctl [OPTIONS...] COMMAND ...
[...]

```

Also, the same Mender CLI commands issued on a terminal on the device (or by SSH) work fine:

```auto
root@osu-00e0709d97ea:~# mender show-artifact
dev-setup-offline-1.0.13
root@osu-00e0709d97ea:~# mender send-inventory
root@osu-00e0709d97ea:~#

```

After some experimentation, I noticed that PATH is set (which is why I can run mount and others), but it is not exported (doesn’t show when you type “env” in a remote shell, but does when using a local shell). Exporting PATH fixes the issue for this terminal session (the issue comes back if the remote shell is closed and reopened):

```auto
root@osu-00e0709d97ea:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
root@osu-00e0709d97ea:~# export PATH
root@osu-00e0709d97ea:~# mender show-artifact
dev-setup-offline-1.0.13
root@osu-00e0709d97ea:~# mender send-inventory
root@osu-00e0709d97ea:~#

```

Is there something missing in the mender-connect client configuration, or systemd service?

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [March 4, 2021, 6:36pm UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/2 "2021-03-04T18:36:52Z")

</div>

Interesting. This does seem like a bug to me. @oleorhagen can you take a look?

In the meantime you _may_ be able to cobble together a workaround in the actual [mender-connect configuration](https://docs.mender.io/add-ons/remote-terminal/mender-connect-configuration-file/mender-connect-configuration-options#shellcommand).

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [March 5, 2021, 9:20am UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/3 "2021-03-05T09:20:47Z")

</div>

This is related to [a discussion we had](https://github.com/mendersoftware/mender-connect/pull/6#discussion_r552448214) in the original implementation about login shells. The suggestion there was to use `su`, but this was turned down. However. it may be possible to fix by passing the `-l` option to the shell. All of `sh`, `bash`, `csh`, `ksh` and `zsh` support this.

Pinging @tranchitella as well.

---

<div class="post-metadata">

**Author:** ![hacpa](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@hacpa](https://hub.mender.io/u/hacpa)\
**Post date:** [March 5, 2021, 3:27pm UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/4 "2021-03-05T15:27:08Z")

</div>

Manually running “/bin/bash -l” from the remote terminal does fix the issue. However, setting “/bin/bash -l” as “ShellCommand” in the config file prevents mender-connect from starting:

```auto
Mar 05 14:40:37 osu-00e0709d97ea mender-connect[530]: time="2021-03-05T14:40:37Z" level=error msg="given shell (/bin/bash -l) is not executable"

```

I also tried with other parameters, like “/bin/bash -i”, to check if the -l was causing the issue, but it still breaks. It seems like adding ANY parameter to “ShellCommand” breaks mender-connect.

---

<div class="post-metadata">

**Author:** ![tranchitella](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tranchitella/32/606_2.png) [@tranchitella](https://hub.mender.io/u/tranchitella)\
**Post date:** [March 6, 2021, 4:49am UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/5 "2021-03-06T04:49:00Z")

</div>

@hacpa I confirm the ShellCommand doesn’t support arguments; if you want to customize it, you need to create a script (which can run bash -i or do whatever initialization you neeed) and point mender-connect to it.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [March 8, 2021, 8:29am UTC](https://hub.mender.io/t/path-issue-when-using-mender-connect/3301/6 "2021-03-08T08:29:25Z")

</div>

Sorry, I should have been clearer: I meant adding `-l` in the Mender source code, so it was primarily a comment aimed at the developers. But you confirmed that adding the parameter worked, so I think it deserves [a ticket](https://tracker.mender.io/browse/MEN-4505).
