RunAnything icon indicating copy to clipboard operation
RunAnything copied to clipboard

File not found error

Open Mabsten opened this issue 4 years ago • 15 comments

I tried this plugin to run a simple cmd command, like echo test, but I get this error:

Cannot run program "echo test" (in directory "C:\my_project_folder"): CreateProcess error=2, File not found

IntelliJ version: 2020.3 (Ultimate Edition) OS: Windows 10 64 bit

Mabsten avatar Feb 17 '21 20:02 Mabsten

My guess is that you have the argument "test" in the "Command" field, and not in the arguments field. Could you confirm this?

Would it help if I named the "Command" field "Program" instead?

AVeenstra avatar Feb 18 '21 11:02 AVeenstra

Yes, I hadn't put the argument in the appropriate field. Separating the arguments, I can run the actual programs (ie executables in the system path), but not windows cmd commands, like echo. In theory your plugin should also support windows cmd commands or does it only support real programs? I was looking for a tool that offered me something similar to the npm scripts - which also allows the execution of cmd commands - to be used not only in node.js projects, but in all types of projects. Anyway, thanks for your reply, I'm glad to see that this plugin is actively maintained. I tried many plugins to make it easier to run/save cmd commands in IntelliJ, but they all had problems and didn't seem to be maintained.

Mabsten avatar Feb 18 '21 19:02 Mabsten

It only supports real programs as the other kind are interpreted by cmd itself, but can't you pass a program as an argument to C:\Windows\System32\cmd.exe?

I am not running Windows at the moment, so I can't experiment right now.

If it does not work please let me know!

AVeenstra avatar Feb 18 '21 19:02 AVeenstra

I cant run commands that loaded in the $PATH.

For example, I want to execute go build I have already had reference to go bin in my $PATH and I have checked Include system environment variables, but it seems I do not respect that option. Also, I tried to overwrite the $PATH but not result unless I used the full path of the executable.

image

AliYusuf95 avatar Mar 14 '21 16:03 AliYusuf95

Kind of same issue here.

Plugin tells me

15:10	Error running 'Run build http2': Cannot run program "simplehttp2server" (in directory "/Users/makedonsky/PycharmProjects/padsplit/eng-front/build"): error=2, No such file or directory

This simplehttp2server is on $PATH and accessible anywhere in the system, but plugin doesn't recognize it unless i explicitly specify full path to the simplehttp2server like that: https://gyazo.com/a49bc757bc0919ec08c9242d43f5e2bf

iMakedonsky avatar Mar 19 '21 13:03 iMakedonsky

Could you show me the output of env, called using the plugin?

AVeenstra avatar Mar 19 '21 15:03 AVeenstra

Here it is, @AVeenstra :


PATH=/usr/bin:/bin:/usr/sbin:/sbin
__CFBundleIdentifier=com.jetbrains.WebStorm
SHELL=/bin/zsh
USER=makedonsky
TMPDIR=/var/folders/81/hnjhdzq11zg__ktzt72kl__00000gn/T/
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.3Kwvhs4p7U/Listeners
XPC_FLAGS=0x0
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
LOGNAME=makedonsky
XPC_SERVICE_NAME=application.com.jetbrains.WebStorm.67265131.67274493
PWD=/Users/makedonsky/PycharmProjects/padsplit/eng-front
HOME=/Users/makedonsky

While normal env from terminal has

PATH=/Users/makedonsky/bin:/usr/local/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/makedonsky/PycharmProjects/padsplit/eng-front/node_modules/.bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/makedonsky/.cache/zsh4humans/v4/fzf/bin

Command I'm trying to run is

❯ which simplehttp2server         
/usr/local/bin/simplehttp2server

iMakedonsky avatar Mar 19 '21 17:03 iMakedonsky

I think I fixed the bug in the next version: https://github.com/AVeenstra/RunAnything/releases/tag/1.2

Could you test it? It is a MacOS specific issue, and I don't have one of those.

I will probably publish it on the Jetbrains marketplace this weekend.

AVeenstra avatar Mar 19 '21 20:03 AVeenstra

Will do when it's live on intellij marketplace @AVeenstra thanks!

iMakedonsky avatar Mar 19 '21 21:03 iMakedonsky

The update will be processed within two business days, so it should be available in the near future. I will consider this issue fixed. Please let me know if this is not the case.

AVeenstra avatar Mar 20 '21 12:03 AVeenstra

I'm not sure if this issue is fixed completely.

image

Shouldn't I be able to run npm if it's in PATH and works properly on command line interpreters? I know I can directly refer to npm executable but doing that kills the cross-platform compatibility of that particular run config.

m4heshd avatar May 20 '22 09:05 m4heshd

Could you confirm that the PATH is listed in the run configuration? So click: image Then make sure you include the system environment variables and that the Path is correct: image

AVeenstra avatar May 20 '22 14:05 AVeenstra

Thanks for the quick response @AVeenstra.

It's enabled and the variable data is correct. Path contains C:\Program Files\nodejs where the npm.cmd is picked up from. It does work if I use the executable directly but the command doesn't. But other commands like docker which are also in Path, does work.

Update: I think it's because the executable is a cmd file. The following works.

image

While this doesn't:

image

But this still raises the issue of cross-compatibility. 🥺 Would you be able to squash this one?

m4heshd avatar May 21 '22 00:05 m4heshd

Your update makes sense, and is also something I can reproduce. You can also reproduce this with the built-in Run Anything window (click if you don't know it already). My plugin uses most of the same code, so squashing this one would require some weird work-arounds that will almost certainly break in future Jetbrains updates.

Instead of doing that I propose we add full cross-compatibility as a feature instead and give more control to the user. However, I am not sure why you would want it. Could you describe your use case in detail so that we can consider an appropriate approach?

Some questions I have:

  • Is OS family the only distinction you want to make? Or do you want to run alternate commands depending on the OS version as well?
  • What are the disadvantages of creating a separate run configuration for each OS? There is support for folders, so you can even group them based on OS.
  • What are the disadvantages of adding the path to the Node interpreter to the PATH? There is a node.exe right?
  • Would you like to select different commands based on environment variables?
  • Would you like to select different commands based on files?
  • Would you like to have the possibility to override all fields based certain criteria? Don't some programs have OS specific flags that break on other platforms?
  • What would be better?
    1. Extra macros to make the commands dynamic based on user given criteria. Probably messy and not clear to users.
    2. Dynamically adding extra input fields to allow for overrides based on user given criteria. Some run configurations dynamically add fields to the UI based on input or button presses, maybe I could do the same? That way the overrides are in view and clear to the user. It might be messy with too many overrides.
    3. Adding tabs for overrides based on user given criteria? Have a tab for each set of criteria and allow for each tab to override the "default" tab.
  • Am I over engineering this?

You don't have to answer (all of) them as long as you are clear enough about what you want to achieve. I would much prefer to provide a good solution rather than fixing this one issue with a hack.

Also, since this is more of a feature request: could you open a new issue/feature request instead of adding to a fixed bug report? That way future visitors can more easily add comments to the appropriate feature request.

AVeenstra avatar May 22 '22 12:05 AVeenstra

Ok that's a lot. Lemme boil it down.

  • All I need is cross-compatible commands like npm to work on all platforms. I commit run configs and I want my team to have to do no extra modifications to get the project running on their platform. Things I write, they're always cross-compatible. Every single script. It's an obsession of mine. It'll be great to be able to have that with just a single file for each task. Maintaining multiple configs for each platform seems cluttery.
  • But as you mentioned, customizability is always good. Dynamic configurations based on platform, .env files, source files or environment variables is always a plus. But simplicity shouldn't be a sacrifice for that.
  • What are the disadvantages of adding the path to the Node interpreter to the PATH? There is a node.exe right?

If you have Node installed, It's most likely already in there. On any platform. That's why the command npm works on interpreters globally. node.exe and npm.cmd resides in the same directory.

m4heshd avatar May 22 '22 23:05 m4heshd