Last time I was debugging mysterious error connected with autorest:
I have to admit that message was not much of help and at first glance I needed to sit back and think where should I start to track this bug. Which rule of 9 debugging rules should I implement first. For the rest of the post I will mention used rules in curly braces, like (make it fail).
Mentioned error showed up when I clicked the button “Generate” on plugin which I use (make it fail). At first I looked for action attached to Generate button (quit thinking and look) . Thankfully I had a source code of plugin, so quick glimpse showed me the line:
private void GenerateButton_Click(object sender, RoutedEventArgs e) { CreateRestClientGeneratorPath(); var process = Process.Start( @"autorest", $@" //some params ); }
as we can see in 4’th line there is call to 'autorest'
command. At this moment I already had some hunch where bug can hide, but let’s put guesswork aside 🙂
Let’s check what we will get when we’ll call this command on cmd line (make it fail – again).
C:\> autorest 'autorest' is not recognized as an internal or external command, operable program or batch file.
Aha moment ! Autorest not installed. But… wait a second, we already installed it:
C:\>npm list -g --depth=0 +-- @angular/cli@7.3.7 `-- autorest@2.0.4283
now, that was confusing…
so quick googling on ‘package not visible from command line but installed in npm ‘ showed advice:
I specified the path $PATH to the directory where the global packages are installed!
Ethan Cabiac
https://stackoverflow.com/questions/50942811/package-installed-globally-via-npm-is-not-visible-in-cmd
Fortunately we had my machine where autorest worked fine quick compare between colleague and mine path showed the issue.
When we added npm to path everything started working fine 🙂
Finally all pieces come into one:
- system tries to run autorest command
- cannot find autorest command on the list of windows commands
- it tries to resolve command from the env vars, or apps defined in env and because npm is not there it tell us that it ‘cannot find file specified’ 🙂