0

Here's the setup:

  • I'm running MX Linux
  • I'm trying to work on a React Native application in Android Studio
  • React Native relies on NodeJS (and thus the node executable) to be available
  • Android Studio starts via a shell script (studio.sh)
  • I use a tool called asdf for version management of things like NodeJS, which sets up shims to redirect the node executable to a versioned one
  • Normally, the shims to redirect the node command are loaded inside ~/.bashrc (or in my case, ~/.zshrc because I use zsh shell)
  • When I go to the terminal and output $PATH, my shims are loaded in there and show in the PATH
  • When I run Android Studio via my .desktop file (whose Exec line looks like: Exec=/home/myuser/android-studio/bin/studio.sh) it cannot locate the node executable
  • It seems like the Linux distro I'm using (MX Linux) uses dash as its default shell
  • If I run cat /proc/<PID>/environ for the Android Studio PID I notice the PATH is missing the shims
  • I've tried:
    • Altering the Exec line in the desktop file to run bash /home/myuser/android-studio/bin/studio.sh
    • Altering the Exec line to add additional PATH values like env PATH="$HOME/.asdf/shims" /home/myuser/...
    • Altering ~/.profile to set up the PATH with the shim values

I've tried everything I can think of to pass these PATH values along to the Android Studio shell script and nothing seems to be working. The only approach that works is for me to start Android Studio from the terminal, and then the PATH is (I assume) inherited and it can find the node executable.

What am I missing here?

aardvarkk
  • 2,269

1 Answers1

0

I ended up creating a wrapper script which I execute from the .desktop file entry.

My .desktop file just points to Exec a new wrapper Bash script I made called studio.bash, whose contents look like this:

#!/bin/bash
. $HOME/.asdf/asdf.sh
. $HOME/android-studio/bin/studio.sh

This seems to correctly run the asdf shell script in order to set up the shims, and then call the shell script to start Android Studio. Took me forever, but it works. Would love other (better?) suggestions to solve this without all the rigamarole.

I think a big part of the problem is confusion around the fact that asdf specifies itself as a bash script, but studio.sh specifies itself as a sh script, and sh maps to dash on my system. With those three things combined, trying to determine which of .bash_profile, .bashrc, .profile, etc. were relevant was a bit mind-bending to me.

aardvarkk
  • 2,269