Closed Bug 1342715 Opened 4 years ago Closed 4 years ago

mach eslint should search $PATH to find binaries (all platforms, not just linux/mac)

Categories

(Firefox Build System :: Lint and Formatting, defect)

3 Branch
defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: emk, Assigned: standard8)

Details

Attachments

(1 file)

I installed node on D: drive bacause my current system drive is SSD whose disk space is precious. But mach eslint could not find the node binary even if I set $PATH environment variable. I had to create an NTFS junction only to satisfy mach eslint.
Assignee: nobody → standard8
Summary: mach eslint should search $PATH to find binaries → mach eslint should search $PATH to find binaries (Windows-only)
Summary: mach eslint should search $PATH to find binaries (Windows-only) → mach eslint should search $PATH to find binaries (all platforms, not just linux/mac)
Comment on attachment 8873830 [details]
Bug 1342715 - Allow node to be in the PATH on Windows, rather than just a set directory.

https://reviewboard.mozilla.org/r/145262/#review149286

::: tools/lint/eslint/setup_helper.py:259
(Diff revision 1)
>          for ext in [".cmd", ".exe", ""]:
>              try:
>                  return which.which(filename + ext, path=get_possible_node_paths_win())
>              except which.WhichError:
>                  pass
>      else:

Rather than handling the path expansion ourselves why not just fall back to calling which with no set of paths to search?
Comment on attachment 8873830 [details]
Bug 1342715 - Allow node to be in the PATH on Windows, rather than just a set directory.

https://reviewboard.mozilla.org/r/145262/#review149286

> Rather than handling the path expansion ourselves why not just fall back to calling which with no set of paths to search?

I was originally trying to keep the which_path function a bit simpler, especially due to all the try/except. However I've reworked that and added a function to handle the try/except, so I think it is clearer overall now.
Comment on attachment 8873830 [details]
Bug 1342715 - Allow node to be in the PATH on Windows, rather than just a set directory.

https://reviewboard.mozilla.org/r/145262/#review149778

Do we actually need to do lookup for multiple file extensions? Which claims that on windows it supports finding anything with PATHEXT extensions and a simple test on my machine confirms that a search for "node" finds "node.EXE".

I think we can simplify this all down to:

    if (windows)
        try which for get_possible_node_paths_win()
        
    try which for the default path
    
Or invert that if you want to test the default path first.
Comment on attachment 8873830 [details]
Bug 1342715 - Allow node to be in the PATH on Windows, rather than just a set directory.

https://reviewboard.mozilla.org/r/145262/#review149778

Unfortunately for npm we need to find the "npm.cmd". If we don't specify an extension, then it finds the "npm" file. This seems to be hard-coded in the which module, and the only way around it is to specify the filename including the extension.
Comment on attachment 8873830 [details]
Bug 1342715 - Allow node to be in the PATH on Windows, rather than just a set directory.

https://reviewboard.mozilla.org/r/145262/#review150840

I think there's something nicer we can do here but I'm going to tinker myself rather than hold up this.
Attachment #8873830 - Flags: review?(dtownsend) → review+
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c0b44852e1e
Allow node to be in the PATH on Windows, rather than just a set directory. r=mossop
https://hg.mozilla.org/mozilla-central/rev/7c0b44852e1e
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Product: Testing → Firefox Build System
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.