atom-import-js icon indicating copy to clipboard operation
atom-import-js copied to clipboard

no imports can be found with watchman

Open TitanNano opened this issue 8 years ago • 12 comments

When ever I install watchman no imports are found. As soon as I uninstall it the imports are found again.

This works for small projects but not for some of the bigger ones. I simply installed watchman, as far as I can tell there is no further configuration required by import-js.

TitanNano avatar Aug 15 '17 07:08 TitanNano

Interesting. Could you

  1. change the logLevel to "debug" in your config
  2. clear the cache by running rm $(importjs cachepath) from your project's root folder (you might have to npm install -g importjs before this since the atom extension has the lib bundled).
  3. then restart atom (or the extension itself, not sure how that works though).
  4. look at the logfile cat $(importjs logpath)

trotzig avatar Aug 15 '17 20:08 trotzig

@trotzig so, the log file from importjs logpath does not exist, but I get an error in the atom error console.

Watchman:  watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= [31mERROR[0m: Unknown option --no-pretty

after this error import-js falls back to resolve the import without watchman, this didn't happen before, but I can't tell what changed.

TitanNano avatar Aug 15 '17 21:08 TitanNano

I think the "fallback" behavior you're seeing is because the cache has been filled once (without watchman). I bet it stays stale though, if you add more modules they won't show up when importing.

What version of watchman are you using? An upgrade might help, as suggested by this related thread.

trotzig avatar Aug 16 '17 15:08 trotzig

yes, you are right, I now installed the latest version.

Importjs log file still doesn't exist:

cat: /var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/importjs.log: No such file or directory

I now don't get any errors in atoms console and the behavior is as before.

I think the "fallback" behavior you're seeing is because the cache has been filled once (without watchman). I deleted all cache DBs but after the fallback behavior occurred a new DB is created.

Also, I think it's definitely some kind of fallback because after the lookup with watchman failed, my breakpoint in the fb-watchman node module is not hit anymore.

TitanNano avatar Aug 16 '17 17:08 TitanNano

Hrm, that's annoying.

The cache file being recreated is by design. import-js will try to recreate this file as soon as it can (whenever you try importing something).

I'm a little bit surprised that the log file isn't there. I wonder if atom is somehow overriding the default tmp folder for the system? Though it should be right there next to the cache files. If I remember correctly, even if you use the default log level it will post a few lines on startup.

trotzig avatar Aug 16 '17 17:08 trotzig

when I run importjs fix <file path> I get a result back. But importjs cachepath gives me this path /var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/import-js-215cee2763d25a940fc5194c3fdd142f.db while the actual db is at: /var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/import-js-683f13e9b2c620cffc97cf16e2004f76.db

there is still no log file.

TitanNano avatar Aug 16 '17 17:08 TitanNano

The cache location difference might be a version mismatch thing. What does importjs --version tell you?

trotzig avatar Aug 16 '17 18:08 trotzig

importjs --version
2.7.0

TitanNano avatar Aug 16 '17 18:08 TitanNano

That's the latest, and assuming atom is configured to auto-update you should be on the same version through the extension (import-js is bundled with the atom extension).

Are you running the importjs fix command on the same file? The cache file will be unique to any project root (defined as a place where there is a package.json file).

trotzig avatar Aug 16 '17 18:08 trotzig

yes I'm up to date with atom-import-js and yes I ran importjs fix on the same file, same package.json.

TitanNano avatar Aug 16 '17 20:08 TitanNano

@trotzig importjs also is broken on some projects for me. I don't know why it suddenly broke.

Also be careful: npm install -g importjs does not install this imports, but another one: https://www.npmjs.com/package/importjs

the right name is: npm install -g import-js. Pretty confusing ;-)

macrozone avatar Aug 18 '17 11:08 macrozone

@macrozone yes I made the same mistake before

TitanNano avatar Aug 18 '17 15:08 TitanNano