0

I'm trying to execute a really simple script that only launches a fake smtp server using a previous preinstalled package via apt-get.

Here is the code of my script (really simple)

echo 'Runs a fake stmp server'
fake-smtp-server

When I run it directly in the terminal, it works without problems:

enter image description here

However when I try to run it via the external tools of intellij, it does not work.

Here is my external tool configuration, I already tried to run with bin/bash and bin/sh and I get the same error with both:

enter image description here

Here is the error I get in Intellij terminal when I run it:

enter image description here

  • 1
    Where is the command `fake-smtp-server`? Could it be a difference in `$PATH` between your shell and IntelliJ? – Biffen Nov 10 '21 at 09:13
  • 1
    Yes there is a difference I added 'echo $PATH' to the script and I get this : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ccastro/Projects/btrace-v2.2.0-bin/bin However when I run it directly with system terminal I get this: /home/ccastro/intellijIdea/bin:/home/ccastro/.nvm/versions/node/v16.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ccastro/Projects/btrace-v2.2.0-bin/bin – César Castro Aroche Nov 10 '21 at 09:21
  • 1
    Is there a way to force intellji to use system $PATH when running an external tool? – César Castro Aroche Nov 10 '21 at 09:21
  • Tag for _either_ `bash` or `sh`, not both at once. They're two different shells; you're using one or the other. (Strictly, `sh` is a POSIX specification for which there are several implementations; one of those implementations is bash running in a feature-restricted mode, but on Ubuntu, `sh` is provided by `dash`, which is not bash at all). – Charles Duffy Nov 10 '21 at 21:57
  • This bad behaviour is new to IntelliJ (WebStorm actually for me). I had some scripts using node commands that have been working from within WebStorm for almost a decade, and I move these script around my new Kubuntu installations. The last installation is my 20.04 of a year and a half ago, and they were working fine. All of a sudden they stopped working around the time this question was asked (Nov 2021) and I had not touched them for a long while. I think the InteliJ platform has created a bug somehow with External Tools environment... – Angelos Pikoulas Dec 09 '21 at 16:25

1 Answers1

1

Add to the PATH the directory where this script is located. Configure this PATH in your user's bash profile startup script and re-login into the system.

As a workaround, you can also run the IDE from the terminal via the idea.sh script.

Andrey
  • 15,144
  • 25
  • 91
  • 187
  • "> user's bash profile startup script and re-login into the system." - I copied .zshrc's $path to .bashrc then restarted system, and it did NOT work. But running the IDE from `webstorm.sh` WORKED (i.e instead of clicking on the Application Icon on start menu. How is that possible? – Angelos Pikoulas Dec 09 '21 at 16:33